From 582e0f127a9e59978052ec74051e388f86597ad1 Mon Sep 17 00:00:00 2001 From: Lisrte Date: Wed, 11 Sep 2024 17:30:30 +0200 Subject: [PATCH 1/2] Refactor Dangling Hvdc model (#379) * Combine HvdcP and HvdcVsc classes in BaseHvdc * Delete DanglingSide * Fix duplication code Signed-off-by: lisrte --- .../dynawo/dsl/DynamicModelsSupplierTest.java | 14 ++--- .../models/hvdc/AbstractHvdcBuilder.java | 23 +++++++- .../hvdc/{AbstractHvdc.java => BaseHvdc.java} | 13 ++++- .../dynawo/models/hvdc/DanglingSide.java | 40 ------------- .../dynawo/models/hvdc/HvdcDangling.java | 57 +++++++++++++++++++ .../com/powsybl/dynawo/models/hvdc/HvdcP.java | 27 --------- .../dynawo/models/hvdc/HvdcPBuilder.java | 18 ++---- .../dynawo/models/hvdc/HvdcPDangling.java | 50 ---------------- .../powsybl/dynawo/models/hvdc/HvdcVsc.java | 26 --------- .../dynawo/models/hvdc/HvdcVscBuilder.java | 16 +----- .../dynawo/models/hvdc/HvdcVscDangling.java | 50 ---------------- .../com/powsybl/dynawo/models/HvdcTest.java | 9 ++- 12 files changed, 107 insertions(+), 236 deletions(-) rename dynawo-simulation/src/main/java/com/powsybl/dynawo/models/hvdc/{AbstractHvdc.java => BaseHvdc.java} (83%) delete mode 100644 dynawo-simulation/src/main/java/com/powsybl/dynawo/models/hvdc/DanglingSide.java create mode 100644 dynawo-simulation/src/main/java/com/powsybl/dynawo/models/hvdc/HvdcDangling.java delete mode 100644 dynawo-simulation/src/main/java/com/powsybl/dynawo/models/hvdc/HvdcP.java delete mode 100644 dynawo-simulation/src/main/java/com/powsybl/dynawo/models/hvdc/HvdcPDangling.java delete mode 100644 dynawo-simulation/src/main/java/com/powsybl/dynawo/models/hvdc/HvdcVsc.java delete mode 100644 dynawo-simulation/src/main/java/com/powsybl/dynawo/models/hvdc/HvdcVscDangling.java diff --git a/dynawo-dsl/src/test/java/com/powsybl/dynawo/dsl/DynamicModelsSupplierTest.java b/dynawo-dsl/src/test/java/com/powsybl/dynawo/dsl/DynamicModelsSupplierTest.java index 48d51f139..3086f7de0 100644 --- a/dynawo-dsl/src/test/java/com/powsybl/dynawo/dsl/DynamicModelsSupplierTest.java +++ b/dynawo-dsl/src/test/java/com/powsybl/dynawo/dsl/DynamicModelsSupplierTest.java @@ -26,10 +26,8 @@ import com.powsybl.dynawo.models.buses.StandardBus; import com.powsybl.dynawo.models.generators.*; import com.powsybl.dynawo.models.loads.*; -import com.powsybl.dynawo.models.hvdc.HvdcP; -import com.powsybl.dynawo.models.hvdc.HvdcPDangling; -import com.powsybl.dynawo.models.hvdc.HvdcVsc; -import com.powsybl.dynawo.models.hvdc.HvdcVscDangling; +import com.powsybl.dynawo.models.hvdc.BaseHvdc; +import com.powsybl.dynawo.models.hvdc.HvdcDangling; import com.powsybl.dynawo.models.lines.StandardLine; import com.powsybl.dynawo.models.svarcs.BaseStaticVarCompensator; import com.powsybl.dynawo.models.transformers.TransformerFixedRatio; @@ -118,10 +116,10 @@ void assertPureDynamicBlackBoxModel(BlackBoxModel bbm, String dynamicId, String private static Stream provideEquipmentModelData() { return Stream.of( Arguments.of("/dynamicModels/bus.groovy", StandardBus.class, EurostagTutorialExample1Factory.create(), "NGEN", "BBM_NGEN", "SB", "Bus"), - Arguments.of("/dynamicModels/hvdcP.groovy", HvdcP.class, HvdcTestNetwork.createVsc(), "L", "BBM_HVDC_L", "HVDC", "HvdcPV"), - Arguments.of("/dynamicModels/hvdcVsc.groovy", HvdcVsc.class, HvdcTestNetwork.createVsc(), "L", "BBM_HVDC_L", "HVDC", "HvdcVSC"), - Arguments.of("/dynamicModels/hvdcPDangling.groovy", HvdcPDangling.class, HvdcTestNetwork.createVsc(), "L", "BBM_HVDC_L", "HVDC", "HvdcPVDanglingDiagramPQ"), - Arguments.of("/dynamicModels/hvdcVscDangling.groovy", HvdcVscDangling.class, HvdcTestNetwork.createVsc(), "L", "BBM_HVDC_L", "HVDC", "HvdcVSCDanglingUdc"), + Arguments.of("/dynamicModels/hvdcP.groovy", BaseHvdc.class, HvdcTestNetwork.createVsc(), "L", "BBM_HVDC_L", "HVDC", "HvdcPV"), + Arguments.of("/dynamicModels/hvdcVsc.groovy", BaseHvdc.class, HvdcTestNetwork.createVsc(), "L", "BBM_HVDC_L", "HVDC", "HvdcVSC"), + Arguments.of("/dynamicModels/hvdcPDangling.groovy", HvdcDangling.class, HvdcTestNetwork.createVsc(), "L", "BBM_HVDC_L", "HVDC", "HvdcPVDanglingDiagramPQ"), + Arguments.of("/dynamicModels/hvdcVscDangling.groovy", HvdcDangling.class, HvdcTestNetwork.createVsc(), "L", "BBM_HVDC_L", "HVDC", "HvdcVSCDanglingUdc"), Arguments.of("/dynamicModels/loadAB.groovy", BaseLoad.class, EurostagTutorialExample1Factory.create(), "LOAD", "LOAD", "LAB", "LoadAlphaBetaRestorative"), Arguments.of("/dynamicModels/loadABControllable.groovy", BaseLoadControllable.class, EurostagTutorialExample1Factory.create(), "LOAD", "LOAD", "LAB", "LoadAlphaBeta"), Arguments.of("/dynamicModels/loadTransformer.groovy", LoadOneTransformer.class, EurostagTutorialExample1Factory.create(), "LOAD", "LOAD", "LOT", "LoadOneTransformer"), diff --git a/dynawo-simulation/src/main/java/com/powsybl/dynawo/models/hvdc/AbstractHvdcBuilder.java b/dynawo-simulation/src/main/java/com/powsybl/dynawo/models/hvdc/AbstractHvdcBuilder.java index 59a7f8bc6..c69818ced 100644 --- a/dynawo-simulation/src/main/java/com/powsybl/dynawo/models/hvdc/AbstractHvdcBuilder.java +++ b/dynawo-simulation/src/main/java/com/powsybl/dynawo/models/hvdc/AbstractHvdcBuilder.java @@ -13,19 +13,26 @@ import com.powsybl.dynawo.builders.BuilderReports; import com.powsybl.iidm.network.*; +import java.util.function.Function; + /** * @author Laurent Issertial {@literal } */ public abstract class AbstractHvdcBuilder> extends AbstractEquipmentModelBuilder { protected TwoSides danglingSide; + private final Function eventVarNameSupplier; - protected AbstractHvdcBuilder(Network network, ModelConfig modelConfig, IdentifiableType identifiableType, ReportNode reportNode) { + protected AbstractHvdcBuilder(Network network, ModelConfig modelConfig, IdentifiableType identifiableType, + ReportNode reportNode, Function eventVarNameSupplier) { super(network, modelConfig, identifiableType, reportNode); + this.eventVarNameSupplier = eventVarNameSupplier; } - protected AbstractHvdcBuilder(Network network, ModelConfig modelConfig, String equipmentType, ReportNode reportNode) { + protected AbstractHvdcBuilder(Network network, ModelConfig modelConfig, String equipmentType, ReportNode reportNode, + Function eventVarNameSupplier) { super(network, modelConfig, equipmentType, reportNode); + this.eventVarNameSupplier = eventVarNameSupplier; } public R dangling(TwoSides danglingSide) { @@ -45,4 +52,16 @@ protected void checkData() { isInstantiable = false; } } + + @Override + public BaseHvdc build() { + if (isInstantiable()) { + if (modelConfig.isDangling()) { + return new HvdcDangling(dynamicModelId, getEquipment(), parameterSetId, modelConfig.lib(), eventVarNameSupplier, danglingSide); + } else { + return new BaseHvdc(dynamicModelId, getEquipment(), parameterSetId, modelConfig.lib(), eventVarNameSupplier); + } + } + return null; + } } diff --git a/dynawo-simulation/src/main/java/com/powsybl/dynawo/models/hvdc/AbstractHvdc.java b/dynawo-simulation/src/main/java/com/powsybl/dynawo/models/hvdc/BaseHvdc.java similarity index 83% rename from dynawo-simulation/src/main/java/com/powsybl/dynawo/models/hvdc/AbstractHvdc.java rename to dynawo-simulation/src/main/java/com/powsybl/dynawo/models/hvdc/BaseHvdc.java index e3c96cf6d..714def9b3 100644 --- a/dynawo-simulation/src/main/java/com/powsybl/dynawo/models/hvdc/AbstractHvdc.java +++ b/dynawo-simulation/src/main/java/com/powsybl/dynawo/models/hvdc/BaseHvdc.java @@ -20,11 +20,12 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import java.util.function.Function; /** * @author Laurent Issertial {@literal } */ -public abstract class AbstractHvdc extends AbstractEquipmentBlackBoxModel implements HvdcModel { +public class BaseHvdc extends AbstractEquipmentBlackBoxModel implements HvdcModel { private static final List VAR_MAPPING = Arrays.asList( new VarMapping("hvdc_PInj1Pu", "p1"), @@ -36,8 +37,11 @@ public abstract class AbstractHvdc extends AbstractEquipmentBlackBoxModel eventVarNameSupplier; + + protected BaseHvdc(String dynamicModelId, HvdcLine hvdc, String parameterSetId, String lib, Function eventVarNameSupplier) { super(dynamicModelId, parameterSetId, hvdc, lib); + this.eventVarNameSupplier = eventVarNameSupplier; } @Override @@ -67,4 +71,9 @@ protected final VarConnection getSimpleVarConnectionWithBus(EquipmentConnectionP public List> getConnectedStations() { return List.of(equipment.getConverterStation1(), equipment.getConverterStation2()); } + + @Override + public String getSwitchOffSignalEventVarName(TwoSides side) { + return eventVarNameSupplier.apply(side); + } } diff --git a/dynawo-simulation/src/main/java/com/powsybl/dynawo/models/hvdc/DanglingSide.java b/dynawo-simulation/src/main/java/com/powsybl/dynawo/models/hvdc/DanglingSide.java deleted file mode 100644 index 04868cb8f..000000000 --- a/dynawo-simulation/src/main/java/com/powsybl/dynawo/models/hvdc/DanglingSide.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.powsybl.dynawo.models.hvdc; - -import com.powsybl.dynawo.models.buses.EquipmentConnectionPoint; -import com.powsybl.dynawo.models.VarConnection; -import com.powsybl.dynawo.models.utils.SideUtils; -import com.powsybl.iidm.network.TwoSides; - -import java.util.List; -import java.util.Objects; -import java.util.function.BiConsumer; -import java.util.function.BiFunction; - -public final class DanglingSide { - - private final String prefix; - private final TwoSides side; - - public DanglingSide(String prefix, TwoSides side) { - this.prefix = Objects.requireNonNull(prefix); - this.side = Objects.requireNonNull(side); - } - - boolean isDangling(TwoSides side) { - return this.side == side; - } - - public int getSideNumber() { - return side.getNum(); - } - - public void createMacroConnections(BiFunction> basicVarConnectionsSupplier, - BiConsumer>, TwoSides> connectionCreator) { - connectionCreator.accept(this::getVarConnectionsWith, side); - connectionCreator.accept(basicVarConnectionsSupplier, SideUtils.getOppositeSide(side)); - } - - private List getVarConnectionsWith(EquipmentConnectionPoint connected, TwoSides side) { - return List.of(new VarConnection(prefix + side.getNum(), connected.getTerminalVarName(side))); - } -} diff --git a/dynawo-simulation/src/main/java/com/powsybl/dynawo/models/hvdc/HvdcDangling.java b/dynawo-simulation/src/main/java/com/powsybl/dynawo/models/hvdc/HvdcDangling.java new file mode 100644 index 000000000..e30b3e04a --- /dev/null +++ b/dynawo-simulation/src/main/java/com/powsybl/dynawo/models/hvdc/HvdcDangling.java @@ -0,0 +1,57 @@ +/** + * Copyright (c) 2023, RTE (http://www.rte-france.com/) + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * SPDX-License-Identifier: MPL-2.0 + */ +package com.powsybl.dynawo.models.hvdc; + +import com.powsybl.commons.PowsyblException; +import com.powsybl.dynawo.models.VarConnection; +import com.powsybl.dynawo.models.buses.EquipmentConnectionPoint; +import com.powsybl.dynawo.models.macroconnections.MacroConnectionsAdder; +import com.powsybl.dynawo.models.utils.SideUtils; +import com.powsybl.iidm.network.HvdcConverterStation; +import com.powsybl.iidm.network.HvdcLine; +import com.powsybl.iidm.network.TwoSides; + +import java.util.List; +import java.util.function.Function; + +/** + * @author Laurent Issertial {@literal } + */ +public class HvdcDangling extends BaseHvdc { + + private final TwoSides danglingSide; + + protected HvdcDangling(String dynamicModelId, HvdcLine hvdc, String parameterSetId, String hvdcLib, + Function eventVarNameSupplier, TwoSides danglingSide) { + super(dynamicModelId, hvdc, parameterSetId, hvdcLib, eventVarNameSupplier); + this.danglingSide = danglingSide; + } + + @Override + public void createMacroConnections(MacroConnectionsAdder adder) { + adder.createTerminalMacroConnections(this, equipment, this::getVarConnectionsWithDangling, danglingSide); + adder.createTerminalMacroConnections(this, equipment, this::getVarConnectionsWith, SideUtils.getOppositeSide(danglingSide)); + } + + @Override + public String getSwitchOffSignalEventVarName(TwoSides side) { + if (danglingSide == side) { + throw new PowsyblException(String.format("Equipment %s side %s is dangling and can't be disconnected with an event", getLib(), side.getNum())); + } + return super.getSwitchOffSignalEventVarName(side); + } + + @Override + public List> getConnectedStations() { + return List.of(danglingSide == TwoSides.ONE ? equipment.getConverterStation2() : equipment.getConverterStation1()); + } + + private List getVarConnectionsWithDangling(EquipmentConnectionPoint connected, TwoSides side) { + return List.of(new VarConnection(TERMINAL_PREFIX + side.getNum(), connected.getTerminalVarName(side))); + } +} diff --git a/dynawo-simulation/src/main/java/com/powsybl/dynawo/models/hvdc/HvdcP.java b/dynawo-simulation/src/main/java/com/powsybl/dynawo/models/hvdc/HvdcP.java deleted file mode 100644 index 559768623..000000000 --- a/dynawo-simulation/src/main/java/com/powsybl/dynawo/models/hvdc/HvdcP.java +++ /dev/null @@ -1,27 +0,0 @@ -/** - * Copyright (c) 2023, RTE (http://www.rte-france.com/) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * SPDX-License-Identifier: MPL-2.0 - */ -package com.powsybl.dynawo.models.hvdc; - -import com.powsybl.dynawo.models.utils.SideUtils; -import com.powsybl.iidm.network.HvdcLine; -import com.powsybl.iidm.network.TwoSides; - -/** - * @author Laurent Issertial {@literal } - */ -public class HvdcP extends AbstractHvdc { - - protected HvdcP(String dynamicModelId, HvdcLine hvdc, String parameterSetId, String hvdcLib) { - super(dynamicModelId, hvdc, parameterSetId, hvdcLib); - } - - @Override - public String getSwitchOffSignalEventVarName(TwoSides side) { - return "hvdc_switchOffSignal2" + SideUtils.getSideSuffix(side); - } -} diff --git a/dynawo-simulation/src/main/java/com/powsybl/dynawo/models/hvdc/HvdcPBuilder.java b/dynawo-simulation/src/main/java/com/powsybl/dynawo/models/hvdc/HvdcPBuilder.java index d3406f388..958498d7a 100644 --- a/dynawo-simulation/src/main/java/com/powsybl/dynawo/models/hvdc/HvdcPBuilder.java +++ b/dynawo-simulation/src/main/java/com/powsybl/dynawo/models/hvdc/HvdcPBuilder.java @@ -9,11 +9,14 @@ import com.powsybl.commons.report.ReportNode; import com.powsybl.dynawo.builders.*; +import com.powsybl.dynawo.models.utils.SideUtils; import com.powsybl.iidm.network.HvdcLine; import com.powsybl.iidm.network.IdentifiableType; import com.powsybl.iidm.network.Network; +import com.powsybl.iidm.network.TwoSides; import java.util.Collection; +import java.util.function.Function; /** * @author Laurent Issertial {@literal } @@ -22,6 +25,7 @@ public class HvdcPBuilder extends AbstractHvdcBuilder { public static final String CATEGORY = "HVDC_P"; private static final ModelConfigs MODEL_CONFIGS = ModelConfigsHandler.getInstance().getModelConfigs(CATEGORY); + private static final Function EVENT_VAR_NAME_SUPPLIER = ts -> String.format("hvdc_switchOffSignal2%s", SideUtils.getSideSuffix(ts)); public static HvdcPBuilder of(Network network) { return of(network, ReportNode.NO_OP); @@ -49,19 +53,7 @@ public static Collection getSupportedModelInfos() { } protected HvdcPBuilder(Network network, ModelConfig modelConfig, ReportNode reportNode) { - super(network, modelConfig, IdentifiableType.HVDC_LINE, reportNode); - } - - @Override - public HvdcP build() { - if (isInstantiable()) { - if (modelConfig.isDangling()) { - return new HvdcPDangling(dynamicModelId, getEquipment(), parameterSetId, modelConfig.lib(), danglingSide); - } else { - return new HvdcP(dynamicModelId, getEquipment(), parameterSetId, modelConfig.lib()); - } - } - return null; + super(network, modelConfig, IdentifiableType.HVDC_LINE, reportNode, EVENT_VAR_NAME_SUPPLIER); } @Override diff --git a/dynawo-simulation/src/main/java/com/powsybl/dynawo/models/hvdc/HvdcPDangling.java b/dynawo-simulation/src/main/java/com/powsybl/dynawo/models/hvdc/HvdcPDangling.java deleted file mode 100644 index 9d732a737..000000000 --- a/dynawo-simulation/src/main/java/com/powsybl/dynawo/models/hvdc/HvdcPDangling.java +++ /dev/null @@ -1,50 +0,0 @@ -/** - * Copyright (c) 2023, RTE (http://www.rte-france.com/) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * SPDX-License-Identifier: MPL-2.0 - */ -package com.powsybl.dynawo.models.hvdc; - -import com.powsybl.commons.PowsyblException; -import com.powsybl.dynawo.models.macroconnections.MacroConnectionsAdder; -import com.powsybl.iidm.network.HvdcConverterStation; -import com.powsybl.iidm.network.HvdcLine; -import com.powsybl.iidm.network.TwoSides; - -import java.util.List; - -/** - * @author Laurent Issertial {@literal } - */ -public class HvdcPDangling extends HvdcP { - - private final DanglingSide danglingSide; - - protected HvdcPDangling(String dynamicModelId, HvdcLine hvdc, String parameterSetId, String hvdcLib, TwoSides danglingSide) { - super(dynamicModelId, hvdc, parameterSetId, hvdcLib); - this.danglingSide = new DanglingSide(TERMINAL_PREFIX, danglingSide); - } - - @Override - public void createMacroConnections(MacroConnectionsAdder adder) { - danglingSide.createMacroConnections( - this::getVarConnectionsWith, - (varCoSupplier, side) -> adder.createTerminalMacroConnections(this, equipment.getConverterStation(side).getTerminal(), varCoSupplier, side) - ); - } - - @Override - public String getSwitchOffSignalEventVarName(TwoSides side) { - if (danglingSide.isDangling(side)) { - throw new PowsyblException(String.format("Equipment %s side %s is dangling and can't be disconnected with an event", getLib(), danglingSide.getSideNumber())); - } - return super.getSwitchOffSignalEventVarName(side); - } - - @Override - public List> getConnectedStations() { - return List.of(danglingSide.isDangling(TwoSides.ONE) ? equipment.getConverterStation2() : equipment.getConverterStation1()); - } -} diff --git a/dynawo-simulation/src/main/java/com/powsybl/dynawo/models/hvdc/HvdcVsc.java b/dynawo-simulation/src/main/java/com/powsybl/dynawo/models/hvdc/HvdcVsc.java deleted file mode 100644 index f7467ef10..000000000 --- a/dynawo-simulation/src/main/java/com/powsybl/dynawo/models/hvdc/HvdcVsc.java +++ /dev/null @@ -1,26 +0,0 @@ -/** - * Copyright (c) 2023, RTE (http://www.rte-france.com/) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * SPDX-License-Identifier: MPL-2.0 - */ -package com.powsybl.dynawo.models.hvdc; - -import com.powsybl.iidm.network.HvdcLine; -import com.powsybl.iidm.network.TwoSides; - -/** - * @author Laurent Issertial {@literal } - */ -public class HvdcVsc extends AbstractHvdc { - - protected HvdcVsc(String dynamicModelId, HvdcLine hvdc, String parameterSetId, String hvdcLib) { - super(dynamicModelId, hvdc, parameterSetId, hvdcLib); - } - - @Override - public String getSwitchOffSignalEventVarName(TwoSides side) { - return "hvdc_Conv" + side.getNum() + "_switchOffSignal2"; - } -} diff --git a/dynawo-simulation/src/main/java/com/powsybl/dynawo/models/hvdc/HvdcVscBuilder.java b/dynawo-simulation/src/main/java/com/powsybl/dynawo/models/hvdc/HvdcVscBuilder.java index 45f2bbb0d..0e9067470 100644 --- a/dynawo-simulation/src/main/java/com/powsybl/dynawo/models/hvdc/HvdcVscBuilder.java +++ b/dynawo-simulation/src/main/java/com/powsybl/dynawo/models/hvdc/HvdcVscBuilder.java @@ -12,6 +12,7 @@ import com.powsybl.iidm.network.*; import java.util.Collection; +import java.util.function.Function; import java.util.function.Predicate; /** @@ -21,6 +22,7 @@ public class HvdcVscBuilder extends AbstractHvdcBuilder { public static final String CATEGORY = "HVDC_VSC"; private static final ModelConfigs MODEL_CONFIGS = ModelConfigsHandler.getInstance().getModelConfigs(CATEGORY); + private static final Function EVENT_VAR_NAME_SUPPLIER = ts -> String.format("hvdc_Conv%s_switchOffSignal2", ts.getNum()); private static final Predicate IS_VSC = eq -> HvdcConverterStation.HvdcType.VSC == eq.getConverterStation1().getHvdcType(); public static HvdcVscBuilder of(Network network) { @@ -49,22 +51,10 @@ public static Collection getSupportedModelInfos() { } protected HvdcVscBuilder(Network network, ModelConfig modelConfig, ReportNode reportNode) { - super(network, modelConfig, "VSC " + IdentifiableType.HVDC_LINE, reportNode); + super(network, modelConfig, "VSC " + IdentifiableType.HVDC_LINE, reportNode, EVENT_VAR_NAME_SUPPLIER); addEquipmentPredicate(IS_VSC); } - @Override - public HvdcVsc build() { - if (isInstantiable()) { - if (modelConfig.isDangling()) { - return new HvdcVscDangling(dynamicModelId, getEquipment(), parameterSetId, modelConfig.lib(), danglingSide); - } else { - return new HvdcVsc(dynamicModelId, getEquipment(), parameterSetId, modelConfig.lib()); - } - } - return null; - } - @Override protected HvdcLine findEquipment(String staticId) { HvdcLine line = network.getHvdcLine(staticId); diff --git a/dynawo-simulation/src/main/java/com/powsybl/dynawo/models/hvdc/HvdcVscDangling.java b/dynawo-simulation/src/main/java/com/powsybl/dynawo/models/hvdc/HvdcVscDangling.java deleted file mode 100644 index e2431331d..000000000 --- a/dynawo-simulation/src/main/java/com/powsybl/dynawo/models/hvdc/HvdcVscDangling.java +++ /dev/null @@ -1,50 +0,0 @@ -/** - * Copyright (c) 2023, RTE (http://www.rte-france.com/) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * SPDX-License-Identifier: MPL-2.0 - */ -package com.powsybl.dynawo.models.hvdc; - -import com.powsybl.commons.PowsyblException; -import com.powsybl.dynawo.models.macroconnections.MacroConnectionsAdder; -import com.powsybl.iidm.network.HvdcConverterStation; -import com.powsybl.iidm.network.HvdcLine; -import com.powsybl.iidm.network.TwoSides; - -import java.util.List; - -/** - * @author Laurent Issertial {@literal } - */ -public class HvdcVscDangling extends HvdcVsc { - - private final DanglingSide danglingSide; - - protected HvdcVscDangling(String dynamicModelId, HvdcLine hvdc, String parameterSetId, String hvdcLib, TwoSides danglingSide) { - super(dynamicModelId, hvdc, parameterSetId, hvdcLib); - this.danglingSide = new DanglingSide(TERMINAL_PREFIX, danglingSide); - } - - @Override - public void createMacroConnections(MacroConnectionsAdder adder) { - danglingSide.createMacroConnections( - this::getVarConnectionsWith, - (varCoSupplier, side) -> adder.createTerminalMacroConnections(this, equipment, varCoSupplier, side) - ); - } - - @Override - public String getSwitchOffSignalEventVarName(TwoSides side) { - if (danglingSide.isDangling(side)) { - throw new PowsyblException(String.format("Equipment %s side %s is dangling and can't be disconnected with an event", getLib(), danglingSide.getSideNumber())); - } - return super.getSwitchOffSignalEventVarName(side); - } - - @Override - public List> getConnectedStations() { - return List.of(danglingSide.isDangling(TwoSides.ONE) ? equipment.getConverterStation2() : equipment.getConverterStation1()); - } -} diff --git a/dynawo-simulation/src/test/java/com/powsybl/dynawo/models/HvdcTest.java b/dynawo-simulation/src/test/java/com/powsybl/dynawo/models/HvdcTest.java index 8c402c93a..16c097248 100644 --- a/dynawo-simulation/src/test/java/com/powsybl/dynawo/models/HvdcTest.java +++ b/dynawo-simulation/src/test/java/com/powsybl/dynawo/models/HvdcTest.java @@ -9,8 +9,7 @@ import com.powsybl.dynawo.models.hvdc.HvdcPBuilder; import com.powsybl.dynawo.models.hvdc.HvdcVscBuilder; -import com.powsybl.dynawo.models.hvdc.HvdcP; -import com.powsybl.dynawo.models.hvdc.HvdcVsc; +import com.powsybl.dynawo.models.hvdc.BaseHvdc; import com.powsybl.iidm.network.HvdcLine; import com.powsybl.iidm.network.Network; import com.powsybl.iidm.network.TwoSides; @@ -28,7 +27,7 @@ class HvdcTest { @Test void testConnectedStation() { Network network = HvdcTestNetwork.createVsc(); - HvdcP hvdc = HvdcPBuilder.of(network, "HvdcPV") + BaseHvdc hvdc = HvdcPBuilder.of(network, "HvdcPV") .dynamicModelId("hvdc") .staticId("L") .parameterSetId("HVDC") @@ -41,7 +40,7 @@ void testDanglingConnectedStation() { Network network = HvdcTestNetwork.createVsc(); HvdcLine line = network.getHvdcLine("L"); - HvdcP hvdcPDangling = HvdcPBuilder.of(network, "HvdcPVDangling") + BaseHvdc hvdcPDangling = HvdcPBuilder.of(network, "HvdcPVDangling") .dynamicModelId("hvdc") .staticId("L") .parameterSetId("HVDC") @@ -50,7 +49,7 @@ void testDanglingConnectedStation() { assertEquals(1, hvdcPDangling.getConnectedStations().size()); assertEquals(line.getConverterStation2(), hvdcPDangling.getConnectedStations().get(0)); - HvdcVsc hvdcVscDangling = HvdcVscBuilder.of(network, "HvdcVSCDanglingP") + BaseHvdc hvdcVscDangling = HvdcVscBuilder.of(network, "HvdcVSCDanglingP") .dynamicModelId("hvdc") .staticId("L") .parameterSetId("HVDC") From cf20f8f906072ec6c15b92ff3775604229c059cc Mon Sep 17 00:00:00 2001 From: Coline Piloquet <55250145+colinepiloquet@users.noreply.github.com> Date: Thu, 19 Sep 2024 13:02:24 +0200 Subject: [PATCH 2/2] Fix dead links referring to powsybl.org. (#376) Signed-off-by: Coline PILOQUET --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index d727d57bf..a5962d814 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ [![Javadocs](https://www.javadoc.io/badge/com.powsybl/powsybl-dynawo.svg?color=blue)](https://www.javadoc.io/doc/com.powsybl/powsybl-dynawo) [![Slack](https://img.shields.io/badge/slack-powsybl-blueviolet.svg?logo=slack)](https://join.slack.com/t/powsybl/shared_invite/zt-rzvbuzjk-nxi0boim1RKPS5PjieI0rA) -[Dynawo](https://dynawo.github.io) is an hybrid C++/Modelica open source suite of simulation tools for power systems. This integration module allows to use [DynaFlow](https://dynawo.github.io/about/dynaflow) for [power flow simulations](https://www.powsybl.org/pages/documentation/simulation/powerflow) and [Dynawo](https://dynawo.github.io) for [time domain simulations](https://www.powsybl.org/pages/documentation/simulation/timedomain). +[Dynawo](https://dynawo.github.io) is an hybrid C++/Modelica open source suite of simulation tools for power systems. This integration module allows to use [DynaFlow](https://dynawo.github.io/about/dynaflow) for [power flow simulations](https://powsybl.readthedocs.io/projects/powsybl-core/en/stable/simulation/loadflow/index.html) and [Dynawo](https://dynawo.github.io) for [time domain simulations](https://powsybl.readthedocs.io/projects/powsybl-core/en/stable/simulation/dynamic/index.html). ## DynaFlow @@ -19,7 +19,7 @@ LoadFlowParameters parameters = LoadFlowParameters.load(); LoadFlow.find("DynaFlow").run(network, parameters); ``` -To learn more about the usage of DynaFlow, read the [dedicated page](https://www.powsybl.org/pages/documentation/simulation/powerflow/dynaflow.html) on our website. +To learn more about the usage of DynaFlow, read the [dedicated page](https://powsybl.readthedocs.io/projects/powsybl-dynawo/en/latest/load_flow/index.html) on our website. ## Dynawo @@ -62,7 +62,7 @@ System.out.println("Timeline:"); result.getTimeLine().forEach(tl -> System.out.printf("[%.8f] %s (on %s)%n", tl.time(), tl.message(), tl.modelName())); ``` -To learn more about the usage of Dynawo, read the [dedicated page](https://www.powsybl.org/pages/documentation/simulation/timedomain/dynawo) on our website. +To learn more about the usage of Dynawo, read the [dedicated page](https://powsybl.readthedocs.io/projects/powsybl-dynawo/en/latest/dynamic_simulation/index.html) on our website. ### Examples