Skip to content

Commit

Permalink
Add check for shunt compensator on section count
Browse files Browse the repository at this point in the history
Signed-off-by: Lilian Houdelet <lhoudelet@oxyl.fr>
  • Loading branch information
lilian-houdelet committed Dec 28, 2023
1 parent 31a56b5 commit 822b3e0
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ public void check(Network network) throws NetworkModificationException {
if (network.getShuntCompensator(modificationInfos.getEquipmentId()) != null) {
throw new NetworkModificationException(SHUNT_COMPENSATOR_ALREADY_EXISTS, modificationInfos.getEquipmentId());
}
if (modificationInfos.getMaximumSectionCount() < 1 || modificationInfos.getSectionCount() < 1 || modificationInfos.getSectionCount() > modificationInfos.getMaximumSectionCount()) {
throw new NetworkModificationException(CREATE_SHUNT_COMPENSATOR_ERROR, modificationInfos.getEquipmentId());
}
ModificationUtils.getInstance().controlConnectivity(network, modificationInfos.getVoltageLevelId(),
modificationInfos.getBusOrBusbarSectionId(), modificationInfos.getConnectionPosition());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
import java.util.ArrayList;
import java.util.List;

import static org.gridsuite.modification.server.NetworkModificationException.Type.SHUNT_COMPENSATOR_NOT_FOUND;
import static org.gridsuite.modification.server.NetworkModificationException.Type.VOLTAGE_LEVEL_NOT_FOUND;
import static org.gridsuite.modification.server.NetworkModificationException.Type.*;

/**
* @author Seddik Yengui <Seddik.yengui at rte-france.com>
Expand Down Expand Up @@ -51,6 +50,19 @@ public void check(Network network) throws NetworkModificationException {
throw new NetworkModificationException(VOLTAGE_LEVEL_NOT_FOUND,
String.format("Voltage level %s does not exist in network", modificationInfos.getVoltageLevelId()));
}

int maximumSectionCount = modificationInfos.getMaximumSectionCount() != null
? modificationInfos.getMaximumSectionCount().getValue()
: shuntCompensator.getMaximumSectionCount();

int sectionCount = modificationInfos.getSectionCount() != null
? modificationInfos.getSectionCount().getValue()
: shuntCompensator.getSectionCount();

if (sectionCount < 1 || maximumSectionCount < 1 || sectionCount > maximumSectionCount) {
throw new NetworkModificationException(MODIFY_SHUNT_COMPENSATOR_ERROR, modificationInfos.getEquipmentId());
}

}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public void testCreateModificationWithShuntCompensatorType() {
@Test
public void testCreateModificationWithSusceptancePerSection() {
VoltageLevel v5 = getNetwork().getVoltageLevel("v5");
createShuntCompensator(v5, "v7shunt", "v7shunt", 6, 225., 10, true, 1, 1, 2, 0, "feeder_v7shunt", 40, ConnectablePosition.Direction.BOTTOM);
createShuntCompensator(v5, "v7shunt", "v7shunt", 6, 225., 10, true, 1, 1, 2, 1, "feeder_v7shunt", 40, ConnectablePosition.Direction.BOTTOM);

var shuntCompensator = getNetwork().getShuntCompensator("v7shunt");
var model = shuntCompensator.getModel(ShuntCompensatorLinearModel.class);
Expand Down

0 comments on commit 822b3e0

Please sign in to comment.