Skip to content

Commit

Permalink
Merge branch 'main' into check-on-compensation-modification
Browse files Browse the repository at this point in the history
  • Loading branch information
EtienneLt committed Oct 21, 2024
2 parents 2fe79aa + 8bd3d78 commit 46dcd2f
Show file tree
Hide file tree
Showing 8 changed files with 225 additions and 105 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
<testcontainers.version>1.16.2</testcontainers.version>
<liquibase-hibernate-package>org.gridsuite.modification.server</liquibase-hibernate-package>
<!-- FIXME: powsybl-network-store modules'version is overloaded in the dependencies section.The overloads and this property below have to be removed at next powsybl-ws-dependencies.version upgrade -->
<powsybl-network-store.version>1.18.1</powsybl-network-store.version>
<powsybl-network-store.version>1.19.0</powsybl-network-store.version>
</properties>

<build>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/**
* Copyright (c) 2024, RTE (http://www.rte-france.com)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package org.gridsuite.modification.server.modifications;

import com.powsybl.iidm.network.IdentifiableType;
import com.powsybl.iidm.network.Switch;
import com.powsybl.iidm.network.Terminal;
import com.powsybl.math.graph.TraverseResult;

/**
* @author Slimane Amar <slimane.amar at rte-france.com>
*/
// FIXME : to remove when this class is available in network-store
public class BusbarSectionFinderTraverser implements Terminal.TopologyTraverser {

private final boolean onlyConnectedBbs;

private String firstTraversedBbsId;

public BusbarSectionFinderTraverser(boolean onlyConnectedBbs) {
this.onlyConnectedBbs = onlyConnectedBbs;
}

@Override
public TraverseResult traverse(Terminal terminal, boolean connected) {
if (terminal.getConnectable().getType() == IdentifiableType.BUSBAR_SECTION) {
firstTraversedBbsId = terminal.getConnectable().getId();
return TraverseResult.TERMINATE_TRAVERSER;
}
return TraverseResult.CONTINUE;
}

@Override
public TraverseResult traverse(Switch aSwitch) {
if (onlyConnectedBbs && aSwitch.isOpen()) {
return TraverseResult.TERMINATE_PATH;
}
return TraverseResult.CONTINUE;
}

public String getFirstTraversedBbsId() {
return firstTraversedBbsId;
}
}

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ private void addExtensionsToStaticVarCompensator(StaticVarCompensatorCreationInf
}

reportInjectionCreationConnectivity(staticVarCompensatorCreationInfos, subReportNode);
createStaticVarCompensatorVoltageRegulation(staticVarCompensatorCreationInfos, staticVarCompensator, voltageLevel, subReportNode);
createStaticVarCompensatorLimitsAndSetpoints(staticVarCompensatorCreationInfos, staticVarCompensator, voltageLevel, subReportNode);
reportStaticVarCompensatorStandbyAutomaton(staticVarCompensatorCreationInfos, staticVarCompensator, subReportNode);
}

Expand Down Expand Up @@ -195,13 +195,18 @@ private void createStaticVarCompensatorInBusBreaker(VoltageLevel voltageLevel, S
addExtensionsToStaticVarCompensator(staticVarCompensatorCreationInfos, staticVarCompensator, voltageLevel, subReportNode);
}

private void createStaticVarCompensatorVoltageRegulation(StaticVarCompensatorCreationInfos staticVarCompensatorCreationInfos,
StaticVarCompensator staticVarCompensator, VoltageLevel voltageLevel, ReportNode subReportNode) {
private void createStaticVarCompensatorLimitsAndSetpoints(StaticVarCompensatorCreationInfos staticVarCompensatorCreationInfos,
StaticVarCompensator staticVarCompensator, VoltageLevel voltageLevel, ReportNode subReportNode) {
List<ReportNode> voltageReports = new ArrayList<>();
voltageReports.add(ModificationUtils.getInstance().buildCreationReport(staticVarCompensatorCreationInfos.getMinSusceptance(), "Susceptance min"));
voltageReports.add(ModificationUtils.getInstance().buildCreationReport(staticVarCompensatorCreationInfos.getMaxSusceptance(), "Susceptance max"));
voltageReports.add(ModificationUtils.getInstance().buildCreationReport(staticVarCompensatorCreationInfos.getMinQAtNominalV(), "Q min at nominal voltage"));
voltageReports.add(ModificationUtils.getInstance().buildCreationReport(staticVarCompensatorCreationInfos.getMaxQAtNominalV(), "Q max at nominal voltage"));
voltageReports.add(ModificationUtils.getInstance().buildCreationReport(staticVarCompensatorCreationInfos.getVoltageSetpoint(), "Voltage set point"));
voltageReports.add(ModificationUtils.getInstance().buildCreationReport(staticVarCompensatorCreationInfos.getReactivePowerSetpoint(), "Reactive power set point"));
voltageReports.add(ModificationUtils.getInstance()
.createEnabledDisabledReport("VoltageRegulationOn", modificationInfos.getVoltageRegulationType() == VoltageRegulationType.DISTANT &&
modificationInfos.getRegulationMode() == StaticVarCompensator.RegulationMode.VOLTAGE));
voltageReports.add(ModificationUtils.getInstance().buildCreationReport(staticVarCompensatorCreationInfos.getVoltageSetpoint(), "Voltage set point"));
if (staticVarCompensatorCreationInfos.getRegulatingTerminalVlId() != null && staticVarCompensatorCreationInfos.getRegulatingTerminalId() != null &&
staticVarCompensatorCreationInfos.getRegulatingTerminalType() != null) {
Terminal terminal = ModificationUtils.getInstance().getTerminalFromIdentifiable(voltageLevel.getNetwork(),
Expand All @@ -212,7 +217,7 @@ private void createStaticVarCompensatorVoltageRegulation(StaticVarCompensatorCre
updateCompensatorRegulatingTerminal(staticVarCompensatorCreationInfos, staticVarCompensator, terminal, voltageReports);
}
}
ModificationUtils.getInstance().reportModifications(subReportNode, voltageReports, "VoltageRegulationCreated", "Voltage regulation");
ModificationUtils.getInstance().reportModifications(subReportNode, voltageReports, "LimitsAndSetpointsCreated", "Limits and Setpoints");
}

private void updateCompensatorRegulatingTerminal(StaticVarCompensatorCreationInfos staticVarCompensatorCreationInfos, StaticVarCompensator staticVarCompensator,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ private Double applyOperation(Operator operator, @Nonnull Double value1, @Nonnul
case SUBTRACTION -> value1 - value2;
case MULTIPLICATION -> value1 * value2;
case DIVISION -> value1 / value2;
case PERCENTAGE -> value1 * (value2 / 100);
case PERCENTAGE -> (value1 / 100) * value2;
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.fasterxml.jackson.core.type.TypeReference;
import com.powsybl.iidm.network.*;
import com.powsybl.iidm.network.extensions.ActivePowerControl;
import com.powsybl.iidm.network.extensions.ConnectablePosition;
import com.powsybl.iidm.network.extensions.GeneratorShortCircuit;
import com.powsybl.iidm.network.extensions.GeneratorStartup;
import lombok.SneakyThrows;
Expand All @@ -24,6 +25,8 @@
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.IntStream;

import static org.gridsuite.modification.server.utils.NetworkUtil.*;
import static org.gridsuite.modification.server.utils.NetworkUtil.createGeneratorOnBus;
import static org.gridsuite.modification.server.utils.TestUtils.assertLogMessage;
import static org.gridsuite.modification.server.utils.assertions.Assertions.assertThat;
import static org.junit.Assert.assertNull;
Expand All @@ -50,6 +53,9 @@ protected ModificationInfos buildModification() {
.equipmentName(new AttributeModification<>("newV1Generator", OperationType.SET))
.voltageLevelId(new AttributeModification<>("v2", OperationType.SET))
.busOrBusbarSectionId(new AttributeModification<>("1B", OperationType.SET))
.connectionName(new AttributeModification<>("idGenerator", OperationType.SET))
.connectionPosition(new AttributeModification<>(1, OperationType.SET))
.connectionDirection(new AttributeModification<>(ConnectablePosition.Direction.TOP, OperationType.SET))
.targetP(new AttributeModification<>(80.0, OperationType.SET))
.targetQ(new AttributeModification<>(40.0, OperationType.SET))
.targetV(new AttributeModification<>(48.0, OperationType.SET))
Expand Down Expand Up @@ -445,6 +451,24 @@ public void testUnsetAttributes() throws Exception {

}

@Test
public void changeGeneratorOnBusBreakerWithoutBusBarSection() throws Exception {
VoltageLevel v1 = createVoltageLevel(getNetwork().getSubstation("s1"), "v11", "v32", TopologyKind.BUS_BREAKER, 380.0);
createBusBarSection(getNetwork().getVoltageLevel("v1"), "1.7", "1.7", 0);
createBus(v1, "bus111", "bus111");
createGeneratorOnBus(v1, "idGenerator1", "bus111", 42.1, 1.0);
GeneratorModificationInfos generatorModificationInfos = GeneratorModificationInfos.builder()
.stashed(false)
.equipmentId("idGenerator1")
.connectionPosition(new AttributeModification<>(1, OperationType.SET))
.build();
String generatorModificationInfosJson = mapper.writeValueAsString(generatorModificationInfos);
mockMvc.perform(post(getNetworkModificationUri()).content(generatorModificationInfosJson).contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isOk());
generatorModificationInfos = (GeneratorModificationInfos) modificationRepository.getModifications(getGroupId(), false, true).get(0);
assertEquals(1, generatorModificationInfos.getConnectionPosition().getValue());
}

@Override
@SneakyThrows
protected void testCreationModificationMessage(ModificationInfos modificationInfos) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -445,4 +445,22 @@ public void changeLineConnectablePosition() throws Exception {
assertEquals(1, createdModification.getConnectionPosition2().getValue());

}

@Test
public void changeLineConnectablePositionWithoutBusBarSection() throws Exception {
LineModificationInfos lineModificationInfos = LineModificationInfos.builder()
.stashed(false)
.equipmentId("line3")
.equipmentName(new AttributeModification<>("LineModified", OperationType.SET))
.connectionName1(new AttributeModification<>("line3", OperationType.SET))
.connectionName2(new AttributeModification<>("line3", OperationType.SET))
.build();
String modificationInfosJson = mapper.writeValueAsString(lineModificationInfos);
mockMvc.perform(post(getNetworkModificationUri()).content(modificationInfosJson).contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isOk());
LineModificationInfos createdModification = (LineModificationInfos) modificationRepository.getModifications(getGroupId(), false, true).get(0);
assertEquals("line3", createdModification.getConnectionName1().getValue());
assertEquals("line3", createdModification.getConnectionName2().getValue());

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,7 @@ public void testChangeConnectionStatus() {
changeConnectionState(getNetwork().getTwoWindingsTransformer("trf2"), TwoSides.ONE, true, true, null);
changeConnectionState(getNetwork().getTwoWindingsTransformer("trf2"), TwoSides.ONE, true, false, null);
changeConnectionState(getNetwork().getTwoWindingsTransformer("trf2"), TwoSides.TWO, true, true, null);
changeConnectionState(getNetwork().getTwoWindingsTransformer("trf2"), TwoSides.TWO, true, false, "Could not disconnect equipment 'trf2' on side TWO");
changeConnectionState(getNetwork().getTwoWindingsTransformer("trf2"), TwoSides.TWO, true, false, "Could not disconnect equipment 'trf2'");
}

@SneakyThrows
Expand Down

0 comments on commit 46dcd2f

Please sign in to comment.