From e84ae5fda47e99c71fa2e8446205b81eb5bd3136 Mon Sep 17 00:00:00 2001 From: Geoffroy Jamgotchian Date: Sun, 5 Jun 2022 21:57:21 +0200 Subject: [PATCH] Fix LfVscConverterStationImpl design (#546) Signed-off-by: Geoffroy Jamgotchian --- .../powsybl/openloadflow/network/LfHvdc.java | 9 ++++--- .../network/LfVscConverterStation.java | 15 ++++++++++++ .../openloadflow/network/impl/LfHvdcImpl.java | 24 +++++++++---------- .../impl/LfVscConverterStationImpl.java | 6 +++-- 4 files changed, 35 insertions(+), 19 deletions(-) create mode 100644 src/main/java/com/powsybl/openloadflow/network/LfVscConverterStation.java diff --git a/src/main/java/com/powsybl/openloadflow/network/LfHvdc.java b/src/main/java/com/powsybl/openloadflow/network/LfHvdc.java index 50b81afd20..5151becf1f 100644 --- a/src/main/java/com/powsybl/openloadflow/network/LfHvdc.java +++ b/src/main/java/com/powsybl/openloadflow/network/LfHvdc.java @@ -6,7 +6,6 @@ */ package com.powsybl.openloadflow.network; -import com.powsybl.openloadflow.network.impl.LfVscConverterStationImpl; import com.powsybl.openloadflow.util.Evaluable; /** @@ -30,13 +29,13 @@ public interface LfHvdc extends LfElement { double getP0(); - LfVscConverterStationImpl getConverterStation1(); + LfVscConverterStation getConverterStation1(); - LfVscConverterStationImpl getConverterStation2(); + LfVscConverterStation getConverterStation2(); - void setConverterStation1(LfVscConverterStationImpl converterStation1); + void setConverterStation1(LfVscConverterStation converterStation1); - void setConverterStation2(LfVscConverterStationImpl converterStation2); + void setConverterStation2(LfVscConverterStation converterStation2); void updateState(); } diff --git a/src/main/java/com/powsybl/openloadflow/network/LfVscConverterStation.java b/src/main/java/com/powsybl/openloadflow/network/LfVscConverterStation.java new file mode 100644 index 0000000000..7ec49f135e --- /dev/null +++ b/src/main/java/com/powsybl/openloadflow/network/LfVscConverterStation.java @@ -0,0 +1,15 @@ +/** + * Copyright (c) 2022, 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/. + */ +package com.powsybl.openloadflow.network; + +/** + * @author Geoffroy Jamgotchian + */ +public interface LfVscConverterStation extends LfGenerator { + + double getLossFactor(); +} diff --git a/src/main/java/com/powsybl/openloadflow/network/impl/LfHvdcImpl.java b/src/main/java/com/powsybl/openloadflow/network/impl/LfHvdcImpl.java index 13fd7d8429..4aa546bf1a 100644 --- a/src/main/java/com/powsybl/openloadflow/network/impl/LfHvdcImpl.java +++ b/src/main/java/com/powsybl/openloadflow/network/impl/LfHvdcImpl.java @@ -34,9 +34,9 @@ public class LfHvdcImpl extends AbstractElement implements LfHvdc { private final double p0; - private LfVscConverterStationImpl vsc1; + private LfVscConverterStation converterStation1; - private LfVscConverterStationImpl vsc2; + private LfVscConverterStation converterStation2; public LfHvdcImpl(String id, LfBus bus1, LfBus bus2, LfNetwork network, HvdcAngleDroopActivePowerControl control) { super(network); @@ -99,31 +99,31 @@ public double getP0() { } @Override - public LfVscConverterStationImpl getConverterStation1() { - return vsc1; + public LfVscConverterStation getConverterStation1() { + return converterStation1; } @Override - public LfVscConverterStationImpl getConverterStation2() { - return vsc2; + public LfVscConverterStation getConverterStation2() { + return converterStation2; } @Override - public void setConverterStation1(LfVscConverterStationImpl converterStation1) { - this.vsc1 = converterStation1; + public void setConverterStation1(LfVscConverterStation converterStation1) { + this.converterStation1 = Objects.requireNonNull(converterStation1); converterStation1.setTargetP(0); } @Override - public void setConverterStation2(LfVscConverterStationImpl converterStation2) { - this.vsc2 = converterStation2; + public void setConverterStation2(LfVscConverterStation converterStation2) { + this.converterStation2 = Objects.requireNonNull(converterStation2); converterStation2.setTargetP(0); } @Override public void updateState() { // Should be done before updating state of generators. - vsc1.setTargetP(-p1.eval()); - vsc2.setTargetP(-p2.eval()); + converterStation1.setTargetP(-p1.eval()); + converterStation2.setTargetP(-p2.eval()); } } diff --git a/src/main/java/com/powsybl/openloadflow/network/impl/LfVscConverterStationImpl.java b/src/main/java/com/powsybl/openloadflow/network/impl/LfVscConverterStationImpl.java index 18c06b37d4..00c5f95dc1 100644 --- a/src/main/java/com/powsybl/openloadflow/network/impl/LfVscConverterStationImpl.java +++ b/src/main/java/com/powsybl/openloadflow/network/impl/LfVscConverterStationImpl.java @@ -7,6 +7,7 @@ package com.powsybl.openloadflow.network.impl; import com.powsybl.iidm.network.*; +import com.powsybl.openloadflow.network.LfVscConverterStation; import com.powsybl.openloadflow.util.PerUnit; import java.util.Objects; @@ -15,11 +16,11 @@ /** * @author Geoffroy Jamgotchian */ -public class LfVscConverterStationImpl extends AbstractLfGenerator { +public class LfVscConverterStationImpl extends AbstractLfGenerator implements LfVscConverterStation { private final VscConverterStation station; - private double lossFactor; + private final double lossFactor; public LfVscConverterStationImpl(VscConverterStation station, boolean breakers, boolean reactiveLimits, LfNetworkLoadingReport report) { super(HvdcConverterStations.getConverterStationTargetP(station)); @@ -37,6 +38,7 @@ public static LfVscConverterStationImpl create(VscConverterStation station, bool return new LfVscConverterStationImpl(station, breakers, reactiveLimits, report); } + @Override public double getLossFactor() { return lossFactor; }