Skip to content

Commit

Permalink
fixing droop
Browse files Browse the repository at this point in the history
Signed-off-by: jamal-khey <myjamal89@gmail.com>
  • Loading branch information
jamal-khey committed Jan 25, 2024
1 parent 4116320 commit 5ade272
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,23 +83,26 @@ private void modifyVsc(@NonNull Network network, @NonNull HvdcLine hvdcLine, Vsc
"Angle drop power control"));
}

if (modificationInfos.getDroop() != null) {
hvdcLine.newExtension(HvdcAngleDroopActivePowerControlAdder.class)
.withDroop(modificationInfos.getDroop().getValue())
.add();
reports.add(ModificationUtils.getInstance().buildModificationReport(
"unknown",
modificationInfos.getDroop().getValue(),
"Angle drop power control"));
}
if (modificationInfos.getP0() != null) {
hvdcLine.newExtension(HvdcAngleDroopActivePowerControlAdder.class)
.withP0(modificationInfos.getP0().getValue())
.add();
reports.add(ModificationUtils.getInstance().buildModificationReport(
"unknown",
modificationInfos.getP0().getValue(),
"p0"));
if (modificationInfos.getDroop() != null ||
modificationInfos.getP0() != null) {
var activePowerControlExtension = hvdcLine.newExtension(HvdcAngleDroopActivePowerControlAdder.class);
activePowerControlExtension.withEnabled(modificationInfos.getAngleDroopActivePowerControl().getValue());
if (modificationInfos.getDroop() != null) {
activePowerControlExtension.withDroop(modificationInfos.getDroop().getValue());
reports.add(ModificationUtils.getInstance().buildModificationReport(
"unknown",
modificationInfos.getDroop().getValue(),
"Angle drop power control"));
}
if (modificationInfos.getP0() != null) {
activePowerControlExtension
.withP0(modificationInfos.getP0().getValue());
reports.add(ModificationUtils.getInstance().buildModificationReport(
"unknown",
modificationInfos.getP0().getValue(),
"p0"));
}
activePowerControlExtension.add();
}

if (modificationInfos.getOperatorActivePowerLimitFromSide1ToSide2() != null ||
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.gridsuite.modification.server.modifications;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.powsybl.iidm.network.*;
import com.powsybl.iidm.network.extensions.HvdcAngleDroopActivePowerControl;
Expand All @@ -12,13 +11,11 @@
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Tag;
import org.springframework.test.web.servlet.MvcResult;
import org.springframework.util.CollectionUtils;

import java.util.*;
import java.util.stream.IntStream;

import static org.gridsuite.modification.server.utils.assertions.Assertions.assertThat;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.jupiter.api.Assertions.assertEquals;
Expand All @@ -37,16 +34,16 @@ protected ModificationInfos buildModification() {
.equipmentId("hvdcLine")
.equipmentName(new AttributeModification<>("hvdcLine", OperationType.SET))
.dcNominalVoltage(new AttributeModification<>(39., OperationType.SET))
.dcResistance(new AttributeModification<>(4., OperationType.SET))
.maximumActivePower(new AttributeModification<>(56., OperationType.SET))
.p0(new AttributeModification<>(5F, OperationType.SET))
.operatorActivePowerLimitFromSide2ToSide1(new AttributeModification<>(5.6F, OperationType.SET))
.convertersMode(new AttributeModification<>(HvdcLine.ConvertersMode.SIDE_1_INVERTER_SIDE_2_RECTIFIER, OperationType.SET))
.activePower(new AttributeModification<>(5., OperationType.SET))
.operatorActivePowerLimitFromSide1ToSide2(new AttributeModification<>(6.0F, OperationType.SET))
.operatorActivePowerLimitFromSide2ToSide1(new AttributeModification<>(8F, OperationType.SET))
.droop(new AttributeModification<>(1F, OperationType.SET))
.angleDroopActivePowerControl(new AttributeModification<>(false, OperationType.SET))
.dcResistance(new AttributeModification<>(4., OperationType.SET))
.maximumActivePower(new AttributeModification<>(56., OperationType.SET))
.p0(new AttributeModification<>(5F, OperationType.SET))
.operatorActivePowerLimitFromSide2ToSide1(new AttributeModification<>(5.6F, OperationType.SET))
.convertersMode(new AttributeModification<>(HvdcLine.ConvertersMode.SIDE_1_INVERTER_SIDE_2_RECTIFIER, OperationType.SET))
.activePower(new AttributeModification<>(5., OperationType.SET))
.operatorActivePowerLimitFromSide1ToSide2(new AttributeModification<>(6.0F, OperationType.SET))
.operatorActivePowerLimitFromSide2ToSide1(new AttributeModification<>(8F, OperationType.SET))
.droop(new AttributeModification<>(1F, OperationType.SET))
.angleDroopActivePowerControl(new AttributeModification<>(true, OperationType.SET))
.converterStation1(buildConverterStationWithMinMaxReactiveLimits())
.converterStation2(buildConverterStationWithReactiveCapabilityCurve())
.build();
Expand All @@ -67,6 +64,7 @@ private ConverterStationModificationInfos buildConverterStationWithReactiveCapab
new ReactiveCapabilityCurveModificationInfos(0.6, 2., 12., 14., 0.8, 0.11)))
.build();
}

private ConverterStationModificationInfos buildConverterStationWithMinMaxReactiveLimits() {
return ConverterStationModificationInfos.builder()
.equipmentId("v2vsc")
Expand Down Expand Up @@ -115,18 +113,16 @@ protected void assertAfterNetworkModificationCreation() {
assertEquals(5., hvdcLine.getActivePowerSetpoint(), 0);
assertEquals(56., hvdcLine.getMaxP(), 0);

//TODO(jamal) check p0 and droop
HvdcOperatorActivePowerRange hvdcOperatorActivePowerRange = hvdcLine.getExtension(HvdcOperatorActivePowerRange.class);
Assert.assertEquals(6, hvdcOperatorActivePowerRange.getOprFromCS1toCS2(), 0);
Assert.assertEquals(8, hvdcOperatorActivePowerRange.getOprFromCS2toCS1(), 0);

HvdcAngleDroopActivePowerControl activePowerControl = hvdcLine.getExtension(HvdcAngleDroopActivePowerControl.class);
Assert.assertEquals(5, activePowerControl.getP0(), 0);
//Assert.assertEquals(1, activePowerControl.getDroop(), 0); //FIXME (jamal) : check droop

Assert.assertEquals(1, activePowerControl.getDroop(), 0);
Assert.assertTrue(activePowerControl.isEnabled());

Assert.assertEquals(HvdcLine.ConvertersMode.SIDE_1_INVERTER_SIDE_2_RECTIFIER, hvdcLine.getConvertersMode());
//TODO (jamal) : check converter stations

Assert.assertEquals(1, getNetwork().getVoltageLevel("v1").getVscConverterStationStream()
.filter(converterStation -> converterStation.getId().equals("v1vsc")).count());
Expand Down Expand Up @@ -158,8 +154,6 @@ protected void assertAfterNetworkModificationCreation() {
assertEquals(modificationPoint.getP(), point.getP());
});
}


Assert.assertEquals(0.3, vscConverterStation1.getVoltageSetpoint(), 0);
Assert.assertEquals("v1", vscConverterStation1.getTerminal().getVoltageLevel().getId());
}
Expand Down Expand Up @@ -191,26 +185,17 @@ protected void testCreationModificationMessage(ModificationInfos modificationInf
@Override
protected void assertAfterNetworkModificationDeletion() {
assertNull(getNetwork().getHvdcLine("vsc1"));
// Assert.assertEquals(0, getNetwork().getVoltageLevel("v1").getVscConverterStationStream()
// .filter(converterStation -> converterStation.getId().equals("stationId1")).count());
//
// Assert.assertEquals(0, getNetwork().getVoltageLevel("v2").getVscConverterStationStream()
// .filter(converterStation -> converterStation.getId().equals("stationId2")).count());
Assert.assertEquals(0, getNetwork().getVoltageLevel("v1").getVscConverterStationStream()
.filter(converterStation -> converterStation.getId().equals("stationId1")).count());

Assert.assertEquals(0, getNetwork().getVoltageLevel("v2").getVscConverterStationStream()
.filter(converterStation -> converterStation.getId().equals("stationId2")).count());
}


@Test
public void testVscModification() throws JsonProcessingException {
MvcResult mvcResult;
Optional<NetworkModificationResult> networkModificationResult;
ModificationInfos modificationToRead = buildModification();

UUID modificationUuid = saveModification(modificationToRead);
//convert modification to json
String resultAsString = mapper.writeValueAsString(modificationToRead);
ModificationInfos receivedModification = mapper.readValue(resultAsString, new TypeReference<>() {
});
public void testDroopUnchanged() throws Exception {

assertThat(receivedModification).recursivelyEquals(modificationToRead);
}

@Override
Expand Down

0 comments on commit 5ade272

Please sign in to comment.