Skip to content

Commit

Permalink
Use default side TwoSides.TWO for dangling hvdc model
Browse files Browse the repository at this point in the history
Nullify dangling side setting in HVDC builder

Signed-off-by: lisrte <laurent.issertial@rte-france.com>
  • Loading branch information
Lisrte authored and flo-dup committed Oct 9, 2024
1 parent f391e9c commit 126b581
Show file tree
Hide file tree
Showing 10 changed files with 63 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -183,14 +183,6 @@ private static Stream<Arguments> provideWarningsModel() {
'dynamicModelId' field is not set, staticId GEN will be used instead
Model GEN cannot be instantiated
"""),
Arguments.of("/warnings/missingDangling.groovy", HvdcTestNetwork.createVsc(),
"""
+ DSL tests
+ Groovy Dynamic Models Supplier
+ DSL model builder for HvdcPVDangling
'dangling' field is not set
Model BBM_HVDC_L cannot be instantiated
"""),
Arguments.of("/warnings/missingDanglingProperty.groovy", HvdcTestNetwork.createVsc(),
"""
+ DSL tests
Expand Down
15 changes: 0 additions & 15 deletions dynawo-dsl/src/test/resources/warnings/missingDangling.groovy

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,15 @@ public static void reportFieldSetWithWrongEquipment(ReportNode reportNode, Strin
.add();
}

public static void reportFieldOptionNotImplemented(ReportNode reportNode, String fieldName, String defaultValue) {
reportNode.newReportNode()
.withMessageTemplate("fieldOptionNotImplemented", "'${fieldName}' field is set but this option is not implemented yet, default value ${defaultValue} will be used")
.withUntypedValue(FIELD_NAME, fieldName)
.withUntypedValue("defaultValue", defaultValue)
.withSeverity(TypedValue.WARN_SEVERITY)
.add();
}

public static void reportFieldConflict(ReportNode reportNode, String firstFieldName, String secondFieldName) {
reportNode.newReportNode()
.withMessageTemplate("fieldConflict", "Both '${firstFieldName}' and '${secondFieldName}' are defined, '${firstFieldName}' will be used")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
*/
public abstract class AbstractHvdcBuilder<R extends AbstractEquipmentModelBuilder<HvdcLine, R>> extends AbstractEquipmentModelBuilder<HvdcLine, R> {

private static final TwoSides DEFAULT_DANGLING_SIDE = TwoSides.TWO;

protected TwoSides danglingSide;
private final HvdcVarNameHandler varNameHandler;

Expand All @@ -42,9 +44,8 @@ public R dangling(TwoSides danglingSide) {
protected void checkData() {
super.checkData();
boolean isDangling = modelConfig.isDangling();
if (isDangling && danglingSide == null) {
BuilderReports.reportFieldNotSet(reportNode, "dangling");
isInstantiable = false;
if (isDangling && danglingSide != null) {
BuilderReports.reportFieldOptionNotImplemented(reportNode, "dangling", DEFAULT_DANGLING_SIDE.toString());
} else if (!isDangling && danglingSide != null) {
BuilderReports.reportFieldSetWithWrongEquipment(reportNode, "dangling", modelConfig.lib());
isInstantiable = false;
Expand All @@ -55,7 +56,7 @@ protected void checkData() {
public BaseHvdc build() {
if (isInstantiable()) {
if (modelConfig.isDangling()) {
return new HvdcDangling(dynamicModelId, getEquipment(), parameterSetId, modelConfig, varNameHandler, danglingSide);
return new HvdcDangling(dynamicModelId, getEquipment(), parameterSetId, modelConfig, varNameHandler, DEFAULT_DANGLING_SIDE);
} else {
return new BaseHvdc(dynamicModelId, getEquipment(), parameterSetId, modelConfig, varNameHandler);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/
package com.powsybl.dynawo.models;

import com.powsybl.commons.report.ReportNode;
import com.powsybl.dynawo.models.hvdc.HvdcPBuilder;
import com.powsybl.dynawo.models.hvdc.HvdcVscBuilder;
import com.powsybl.dynawo.models.hvdc.BaseHvdc;
Expand All @@ -16,6 +17,9 @@
import com.powsybl.iidm.network.test.HvdcTestNetwork;
import org.junit.jupiter.api.Test;

import java.util.Objects;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;

Expand All @@ -39,21 +43,10 @@ void testConnectedStation() {
void testDanglingConnectedStation() {
Network network = HvdcTestNetwork.createVsc();
HvdcLine line = network.getHvdcLine("L");

BaseHvdc hvdcPDangling = HvdcPBuilder.of(network, "HvdcPVDangling")
.dynamicModelId("hvdc")
.staticId("L")
.parameterSetId("HVDC")
.dangling(TwoSides.ONE)
.build();
assertEquals(1, hvdcPDangling.getConnectedStations().size());
assertEquals(line.getConverterStation2(), hvdcPDangling.getConnectedStations().get(0));

BaseHvdc hvdcVscDangling = HvdcVscBuilder.of(network, "HvdcVscDanglingP")
BaseHvdc hvdcVscDangling = HvdcVscBuilder.of(network, "HvdcVSCDanglingP")
.dynamicModelId("hvdc")
.staticId("L")
.parameterSetId("HVDC")
.dangling(TwoSides.TWO)
.build();
assertEquals(1, hvdcVscDangling.getConnectedStations().size());
assertEquals(line.getConverterStation1(), hvdcVscDangling.getConnectedStations().get(0));
Expand All @@ -68,4 +61,31 @@ void vscDynamicModelOnLCC() {
.parameterSetId("HVDC")
.build());
}

@Test
void testDefaultDanglingSide() {
ReportNode reportNode = ReportNode.newRootReportNode()
.withMessageTemplate("hvdcBuilder", "HVDC builder")
.build();
Network network = HvdcTestNetwork.createVsc();
HvdcLine line = network.getHvdcLine("L");

// dangling side ONE replaced by side TWO
BaseHvdc hvdcPDangling = Objects.requireNonNull(
HvdcPBuilder.of(network, "HvdcPVDangling", reportNode))
.dynamicModelId("hvdc")
.staticId("L")
.parameterSetId("HVDC")
.dangling(TwoSides.ONE)
.build();
assertEquals(1, hvdcPDangling.getConnectedStations().size());
assertEquals(line.getConverterStation1(), hvdcPDangling.getConnectedStations().get(0));
assertThat(reportNode.getChildren().stream()
.filter(r -> r.getMessageKey().equalsIgnoreCase("fieldOptionNotImplemented"))
.findFirst())
.isNotEmpty()
.get()
.hasFieldOrPropertyWithValue("message",
"'dangling' field is set but this option is not implemented yet, default value TWO will be used");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,12 @@ private static Stream<Arguments> provideModels() {
.dynamicModelId(DYN_HVDC_NAME)
.staticId(HVDC_NAME)
.parameterSetId("hvdc")
.dangling(TwoSides.ONE)
.dangling(TwoSides.TWO)
.build(),
(Function<Network, BlackBoxModel>) n -> EventDisconnectionBuilder.of(n)
.staticId(HVDC_NAME)
.startTime(1)
.disconnectOnly(TwoSides.TWO)
.disconnectOnly(TwoSides.ONE)
.build())
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ void disconnectionOnDanglingSide(String exception, TwoSides side, BiFunction<Net

private static Stream<Arguments> provideModels() {
return Stream.of(
Arguments.of("Equipment HvdcPVDangling side 1 is dangling and can't be disconnected with an event",
TwoSides.ONE,
Arguments.of("Equipment HvdcPVDangling side 2 is dangling and can't be disconnected with an event",
TwoSides.TWO,
(BiFunction<Network, TwoSides, BlackBoxModel>) (network, side) -> HvdcPBuilder.of(network, "HvdcPVDangling")
.dynamicModelId("BBM_L")
.staticId("L")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import com.powsybl.dynawo.models.hvdc.HvdcVscBuilder;
import com.powsybl.dynawo.models.BlackBoxModel;
import com.powsybl.iidm.network.Network;
import com.powsybl.iidm.network.TwoSides;
import com.powsybl.iidm.network.test.HvdcTestNetwork;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.extension.ExtendWith;
Expand Down Expand Up @@ -71,13 +70,11 @@ private static Stream<Arguments> provideHvdc() {
.dynamicModelId(DYN_NAME)
.staticId(HVDC_NAME)
.parameterSetId("hv")
.dangling(TwoSides.ONE)
.build()),
Arguments.of("hvdc_vsc_dangling_dyd.xml", (Function<Network, BlackBoxModel>) n -> HvdcVscBuilder.of(n, "HvdcVscDanglingP")
.dynamicModelId(DYN_NAME)
.staticId(HVDC_NAME)
.parameterSetId("hv")
.dangling(TwoSides.TWO)
.build())
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
<dyn:macroStaticRef id="MSR_HvdcVscDanglingUdc"/>
</dyn:blackBoxModel>
<dyn:blackBoxModel id="Disconnect_L" lib="EventSetPointBoolean" parFile="hvdctest.par" parId="Disconnect_L"/>
<dyn:macroConnector id="MC_HvdcVscDanglingUdcSide1-DefaultEquipmentConnectionPoint">
<dyn:connect var1="hvdc_terminal1" var2="@STATIC_ID@@NODE1@_ACPIN"/>
</dyn:macroConnector>
<dyn:macroConnector id="MC_HvdcVscDanglingUdcSide2-DefaultEquipmentConnectionPoint">
<dyn:connect var1="hvdc_terminal2" var2="@STATIC_ID@@NODE2@_ACPIN"/>
<dyn:connect var1="hvdc_Conv2_switchOffSignal1" var2="@STATIC_ID@@NODE2@_switchOff"/>
</dyn:macroConnector>
<dyn:macroConnector id="MC_EventHvdcDisconnectionSide2-HvdcVscDanglingUdc">
<dyn:connect var1="event_state1" var2="hvdc_Conv2_switchOffSignal2"/>
<dyn:macroConnector id="MC_HvdcVscDanglingUdcSide1-DefaultEquipmentConnectionPoint">
<dyn:connect var1="hvdc_terminal1" var2="@STATIC_ID@@NODE1@_ACPIN"/>
<dyn:connect var1="hvdc_Conv1_switchOffSignal1" var2="@STATIC_ID@@NODE1@_switchOff"/>
</dyn:macroConnector>
<dyn:macroConnector id="MC_EventHvdcDisconnectionSide1-HvdcVscDanglingUdc">
<dyn:connect var1="event_state1" var2="hvdc_Conv1_switchOffSignal2"/>
</dyn:macroConnector>
<dyn:macroStaticReference id="MSR_HvdcVscDanglingUdc">
<dyn:staticRef var="hvdc_PInj1Pu" staticVar="p1"/>
Expand All @@ -22,7 +22,7 @@
<dyn:staticRef var="hvdc_QInj2Pu" staticVar="q2"/>
<dyn:staticRef var="hvdc_state" staticVar="state2"/>
</dyn:macroStaticReference>
<dyn:macroConnect connector="MC_HvdcVscDanglingUdcSide1-DefaultEquipmentConnectionPoint" id1="BBM_HVDC" id2="NETWORK"/>
<dyn:macroConnect connector="MC_HvdcVscDanglingUdcSide2-DefaultEquipmentConnectionPoint" id1="BBM_HVDC" id2="NETWORK"/>
<dyn:macroConnect connector="MC_EventHvdcDisconnectionSide2-HvdcVscDanglingUdc" id1="Disconnect_L" id2="BBM_HVDC"/>
<dyn:macroConnect connector="MC_HvdcVscDanglingUdcSide1-DefaultEquipmentConnectionPoint" id1="BBM_HVDC" id2="NETWORK"/>
<dyn:macroConnect connector="MC_EventHvdcDisconnectionSide1-HvdcVscDanglingUdc" id1="Disconnect_L" id2="BBM_HVDC"/>
</dyn:dynamicModelsArchitecture>
10 changes: 5 additions & 5 deletions dynawo-simulation/src/test/resources/hvdc_p_dangling_dyd.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
<dyn:blackBoxModel id="BBM_L" lib="HvdcPVDangling" parFile="models.par" parId="hv" staticId="L">
<dyn:macroStaticRef id="MSR_HvdcPVDangling"/>
</dyn:blackBoxModel>
<dyn:macroConnector id="MC_HvdcPVDanglingSide1-DefaultEquipmentConnectionPoint">
<dyn:connect var1="hvdc_terminal1" var2="@STATIC_ID@@NODE1@_ACPIN"/>
</dyn:macroConnector>
<dyn:macroConnector id="MC_HvdcPVDanglingSide2-DefaultEquipmentConnectionPoint">
<dyn:connect var1="hvdc_terminal2" var2="@STATIC_ID@@NODE2@_ACPIN"/>
<dyn:connect var1="hvdc_switchOffSignal1Side2" var2="@STATIC_ID@@NODE2@_switchOff"/>
</dyn:macroConnector>
<dyn:macroConnector id="MC_HvdcPVDanglingSide1-DefaultEquipmentConnectionPoint">
<dyn:connect var1="hvdc_terminal1" var2="@STATIC_ID@@NODE1@_ACPIN"/>
<dyn:connect var1="hvdc_switchOffSignal1Side1" var2="@STATIC_ID@@NODE1@_switchOff"/>
</dyn:macroConnector>
<dyn:macroStaticReference id="MSR_HvdcPVDangling">
<dyn:staticRef var="hvdc_PInj1Pu" staticVar="p1"/>
Expand All @@ -18,6 +18,6 @@
<dyn:staticRef var="hvdc_QInj2Pu" staticVar="q2"/>
<dyn:staticRef var="hvdc_state" staticVar="state2"/>
</dyn:macroStaticReference>
<dyn:macroConnect connector="MC_HvdcPVDanglingSide1-DefaultEquipmentConnectionPoint" id1="BBM_L" id2="NETWORK"/>
<dyn:macroConnect connector="MC_HvdcPVDanglingSide2-DefaultEquipmentConnectionPoint" id1="BBM_L" id2="NETWORK"/>
<dyn:macroConnect connector="MC_HvdcPVDanglingSide1-DefaultEquipmentConnectionPoint" id1="BBM_L" id2="NETWORK"/>
</dyn:dynamicModelsArchitecture>

0 comments on commit 126b581

Please sign in to comment.