diff --git a/src/main/java/org/gridsuite/modification/server/modifications/VscModification.java b/src/main/java/org/gridsuite/modification/server/modifications/VscModification.java index 784c1f888..0eb7956b9 100644 --- a/src/main/java/org/gridsuite/modification/server/modifications/VscModification.java +++ b/src/main/java/org/gridsuite/modification/server/modifications/VscModification.java @@ -51,10 +51,22 @@ public void check(Network network) throws NetworkModificationException { || modificationInfos.getConverterStation2() == null) { throw new NetworkModificationException(MODIFY_BATTERY_ERROR, "Missing required attributes to modify the equipment"); } - VscConverterStation converterStation1 = ModificationUtils.getInstance().getVscConverterStation(network, modificationInfos.getConverterStation1().getEquipmentId()); - VscConverterStation converterStation2 = ModificationUtils.getInstance().getVscConverterStation(network, modificationInfos.getConverterStation2().getEquipmentId()); + HvdcLine hvdcLine = ModificationUtils.getInstance().getHvdcLine(network, modificationInfos.getEquipmentId()); + + VscConverterStation converterStation1 = ModificationUtils.getInstance().getVscConverterStation(network, hvdcLine.getConverterStation1().getId()); + VscConverterStation converterStation2 = ModificationUtils.getInstance().getVscConverterStation(network, hvdcLine.getConverterStation2().getId()); checkConverterStation(modificationInfos.getConverterStation1(), converterStation1); checkConverterStation(modificationInfos.getConverterStation2(), converterStation2); + + checkDroopModification(); + + } + + private void checkDroopModification() { + // if droop is set p0 should be also + if (modificationInfos.getP0() == null && modificationInfos.getDroop() != null) { + throw new NetworkModificationException(MODIFY_VSC_ERROR, "P0 is required to modify the equipment"); + } } @Override @@ -92,8 +104,8 @@ private void modifyVsc(@NonNull Network network, @NonNull HvdcLine hvdcLine, Vsc operatorActivePowerLimit(hvdcLine, modificationInfos, subReportNode); // stations - modifyConverterStation(network, modificationInfos.getConverterStation1(), subReportNode); - modifyConverterStation(network, modificationInfos.getConverterStation2(), subReportNode); + modifyConverterStation(ModificationUtils.getInstance().getVscConverterStation(network, hvdcLine.getConverterStation1().getId()), modificationInfos.getConverterStation1(), subReportNode); + modifyConverterStation(ModificationUtils.getInstance().getVscConverterStation(network, hvdcLine.getConverterStation2().getId()), modificationInfos.getConverterStation2(), subReportNode); PropertiesUtils.applyProperties(hvdcLine, subReportNode, modificationInfos.getProperties(), "VscProperties"); } @@ -245,11 +257,11 @@ private List hvdcAngleDroopActivePowerControlAdder(HvdcLine hvdcLine return reports; } - private void modifyConverterStation(Network network, ConverterStationModificationInfos converterStationModificationInfos, ReportNode subReportNode) { + private void modifyConverterStation(VscConverterStation converterStation, ConverterStationModificationInfos converterStationModificationInfos, ReportNode subReportNode) { if (converterStationModificationInfos == null || !isConverterStationModified(converterStationModificationInfos)) { return; } - VscConverterStation converterStation = ModificationUtils.getInstance().getVscConverterStation(network, converterStationModificationInfos.getEquipmentId()); + ReportNode converterStationReportNode = subReportNode.newReportNode() .withMessageTemplate("Converter Station", "Converter station ${id} modified") .withUntypedValue("id", converterStation.getId()) diff --git a/src/test/java/org/gridsuite/modification/server/modifications/VscModificationTest.java b/src/test/java/org/gridsuite/modification/server/modifications/VscModificationTest.java index 2ee044ce4..caaa54e9a 100644 --- a/src/test/java/org/gridsuite/modification/server/modifications/VscModificationTest.java +++ b/src/test/java/org/gridsuite/modification/server/modifications/VscModificationTest.java @@ -63,8 +63,8 @@ protected ModificationInfos buildModification() { .operatorActivePowerLimitFromSide2ToSide1(new AttributeModification<>(8F, OperationType.SET)) .droop(new AttributeModification<>(1F, OperationType.SET)) .angleDroopActivePowerControl(new AttributeModification<>(true, OperationType.SET)) - .converterStation1(buildConverterStationWithMinMaxReactiveLimits()) - .converterStation2(buildConverterStationWithReactiveCapabilityCurve()) + .converterStation1(buildConverterStationWithReactiveCapabilityCurve()) + .converterStation2(buildConverterStationWithMinMaxReactiveLimits()) .properties(List.of(FreePropertyInfos.builder().name(PROPERTY_NAME).value(PROPERTY_VALUE).build())) .build(); } @@ -171,7 +171,7 @@ protected void assertAfterNetworkModificationCreation() { Assert.assertEquals(2, reactiveLimits1.getPointCount()); Collection points = vscConverterStation1.getReactiveLimits(ReactiveCapabilityCurve.class).getPoints(); List vscPoints = new ArrayList<>(points); - List modificationPoints = vscModificationInfos.getConverterStation2().getReactiveCapabilityCurvePoints(); + List modificationPoints = vscModificationInfos.getConverterStation1().getReactiveCapabilityCurvePoints(); if (!CollectionUtils.isEmpty(points)) { IntStream.range(0, vscPoints.size()) .forEach(i -> { @@ -262,6 +262,28 @@ public void testUnchangedHVDCangleDroopActivePowerControl() throws Exception { Assert.assertTrue(activePowerControl.isEnabled()); } + @Test + public void testHvdcAngleDroopActivePowerControlWithoutP0() { + var networkuuid = UUID.randomUUID(); + Network networkWitoutExt = NetworkCreation.createWithVSC(networkuuid, true); + VscModificationInfos modificationInfos = (VscModificationInfos) buildModification(); + modificationInfos.setAngleDroopActivePowerControl(new AttributeModification<>(true, OperationType.SET)); + { //Test : p0 should be required if drop is changed + modificationInfos.setDroop(new AttributeModification<>(10F, OperationType.SET)); + modificationInfos.setP0(null); + VscModification vscModification = new VscModification(modificationInfos); + Assert.assertThrows(NetworkModificationException.class, () -> vscModification.check(networkWitoutExt)); + } + { //Test : p0 should not be required if drop unchanged + modificationInfos.setDroop(null); + modificationInfos.setP0(new AttributeModification<>(10F, OperationType.SET)); + VscModification vscModification = new VscModification(modificationInfos); + assertDoesNotThrow(() -> vscModification.check(networkWitoutExt)); + + } + + } + @Override @SneakyThrows protected void testUpdateModificationMessage(ModificationInfos modificationInfos) {