Skip to content

Commit

Permalink
Merge branch 'main' into apply_existing_modifications_from_uuids
Browse files Browse the repository at this point in the history
  • Loading branch information
FranckLecuyer authored Aug 2, 2024
2 parents b947b94 + 54d3511 commit 8d95944
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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");
}
Expand Down Expand Up @@ -245,11 +257,11 @@ private List<ReportNode> 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())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down Expand Up @@ -171,7 +171,7 @@ protected void assertAfterNetworkModificationCreation() {
Assert.assertEquals(2, reactiveLimits1.getPointCount());
Collection<ReactiveCapabilityCurve.Point> points = vscConverterStation1.getReactiveLimits(ReactiveCapabilityCurve.class).getPoints();
List<ReactiveCapabilityCurve.Point> vscPoints = new ArrayList<>(points);
List<ReactiveCapabilityCurveModificationInfos> modificationPoints = vscModificationInfos.getConverterStation2().getReactiveCapabilityCurvePoints();
List<ReactiveCapabilityCurveModificationInfos> modificationPoints = vscModificationInfos.getConverterStation1().getReactiveCapabilityCurvePoints();
if (!CollectionUtils.isEmpty(points)) {
IntStream.range(0, vscPoints.size())
.forEach(i -> {
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 8d95944

Please sign in to comment.