Skip to content

Commit

Permalink
check droop while creation
Browse files Browse the repository at this point in the history
  • Loading branch information
thangqp committed Aug 23, 2024
1 parent ca0a381 commit f3f5a71
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,7 @@
import com.powsybl.commons.report.TypedValue;
import com.powsybl.iidm.modification.topology.CreateFeederBay;
import com.powsybl.iidm.modification.topology.CreateFeederBayBuilder;
import com.powsybl.iidm.network.Bus;
import com.powsybl.iidm.network.HvdcLine;
import com.powsybl.iidm.network.Network;
import com.powsybl.iidm.network.TopologyKind;
import com.powsybl.iidm.network.VoltageLevel;
import com.powsybl.iidm.network.VscConverterStation;
import com.powsybl.iidm.network.VscConverterStationAdder;
import com.powsybl.iidm.network.*;
import com.powsybl.iidm.network.extensions.HvdcAngleDroopActivePowerControlAdder;
import com.powsybl.iidm.network.extensions.HvdcOperatorActivePowerRangeAdder;
import org.gridsuite.modification.server.NetworkModificationException;
Expand All @@ -28,8 +22,8 @@
import java.util.List;
import java.util.Map;

import static org.gridsuite.modification.server.NetworkModificationException.Type.CREATE_VSC_ERROR;
import static org.gridsuite.modification.server.NetworkModificationException.Type.HVDC_LINE_ALREADY_EXISTS;
import static org.gridsuite.modification.server.NetworkModificationException.Type.*;
import static org.gridsuite.modification.server.modifications.VscModification.DROOP_AND_P0_FIELD;

/**
* @author Seddik Yengui <seddik.yengui at rte-france.com>
Expand All @@ -39,6 +33,7 @@ public class VscCreation extends AbstractModification {

public static final String VSC_SETPOINTS = "vscSetPoints";
public static final String VSC_CHARACTERISTICS = "vscCharacteristics";
public static final String ACTIVE_POWER_CONTROL_EXTENSION_CREATE_ERROR_MESSAGE = "Both %s are required when angle droop active power control is activated to create a new equipment";

private final VscCreationInfos modificationInfos;

Expand All @@ -54,6 +49,20 @@ public void check(Network network) throws NetworkModificationException {

checkConverterStation(network, modificationInfos.getConverterStation1());
checkConverterStation(network, modificationInfos.getConverterStation2());
checkDroop();
}

private void checkDroop() {
// extension is not enabled => ignore check inside fields
if (modificationInfos.getAngleDroopActivePowerControl() == null || !modificationInfos.getAngleDroopActivePowerControl()) {
return;
}

// enable the extension => should verify whether all fields have been filled
if (modificationInfos.getDroop() == null || modificationInfos.getP0() == null) {
throw new NetworkModificationException(WRONG_HVDC_ANGLE_DROOP_ACTIVE_POWER_CONTROL,
String.format(ACTIVE_POWER_CONTROL_EXTENSION_CREATE_ERROR_MESSAGE, DROOP_AND_P0_FIELD));
}
}

private void checkConverterStation(Network network,
Expand Down Expand Up @@ -100,20 +109,15 @@ public void apply(Network network, ReportNode subReportNode) {
.add();
}

if (modificationInfos.getDroop() != null ||
modificationInfos.getP0() != null) {
if (shouldCreateDroopActivePowerControlExtension()) {
var activePowerControlExtension = hvdcLine.newExtension(HvdcAngleDroopActivePowerControlAdder.class)
.withEnabled(modificationInfos.getAngleDroopActivePowerControl());
if (modificationInfos.getP0() != null) {
activePowerControlExtension.withP0(modificationInfos.getP0());
}

if (modificationInfos.getDroop() != null) {
activePowerControlExtension.withDroop(modificationInfos.getDroop());
}
activePowerControlExtension.withP0(modificationInfos.getP0());
activePowerControlExtension.withDroop(modificationInfos.getDroop());

activePowerControlExtension.add();
}

reportHvdcLineInfos(subReportNode);

subReportNode.newReportNode()
Expand All @@ -130,6 +134,13 @@ public void apply(Network network, ReportNode subReportNode) {
PropertiesUtils.applyProperties(hvdcLine, subReportNode, modificationInfos.getProperties(), "VscProperties");
}

private boolean shouldCreateDroopActivePowerControlExtension() {
return modificationInfos.getAngleDroopActivePowerControl() != null &&
modificationInfos.getAngleDroopActivePowerControl() &&
modificationInfos.getDroop() != null &&
modificationInfos.getP0() != null;
}

private void reportHvdcLineInfos(ReportNode subReportNode) {
List<ReportNode> characteristicsReports = new ArrayList<>();
characteristicsReports.add(ModificationUtils.getInstance().buildCreationReport(modificationInfos.getNominalV(), "DC nominal voltage"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ private void modifyExistingHvdcAngleDroopActivePowerControl(HvdcAngleDroopActive
});
}

protected boolean shouldCreateDroopActivePowerControlExtension() {
private boolean shouldCreateDroopActivePowerControlExtension() {
return modificationInfos.getAngleDroopActivePowerControl() != null &&
modificationInfos.getAngleDroopActivePowerControl().getValue() &&
modificationInfos.getDroop() != null &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ protected ModificationInfos buildModification() {
.operatorActivePowerLimitFromSide1ToSide2(6.0F)
.operatorActivePowerLimitFromSide2ToSide1(8F)
.droop(1F)
.angleDroopActivePowerControl(false)
.angleDroopActivePowerControl(true)
.converterStation1(buildConverterStationWithReactiveCapabilityCurve())
.converterStation2(buildConverterStationWithMinMaxReactiveLimits())
.properties(List.of(FreePropertyInfos.builder().name(PROPERTY_NAME).value(PROPERTY_VALUE).build()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,15 +343,6 @@ protected void testUpdateModificationMessage(ModificationInfos modificationInfos
assertEquals("vsc1Edited", updatedValues.get("equipmentId"));
}

@Test
public void testShouldCreateDroopActivePowerControlExtension() {
VscModificationInfos modificationInfos = (VscModificationInfos) buildModification();
modificationInfos.setAngleDroopActivePowerControl(new AttributeModification<>(true, OperationType.SET));
modificationInfos.setDroop(null);
VscModification vscModification = new VscModification(modificationInfos);
Assert.assertFalse(vscModification.shouldCreateDroopActivePowerControlExtension());
}

@Test
public void testDtoContainRequiredData() {
VscModificationInfos modificationInfos = VscModificationInfos.builder()
Expand Down

0 comments on commit f3f5a71

Please sign in to comment.