diff --git a/src/main/java/com/powsybl/openloadflow/ac/equations/AbstractHvdcAcEmulationFlowEquationTerm.java b/src/main/java/com/powsybl/openloadflow/ac/equations/AbstractHvdcAcEmulationFlowEquationTerm.java index b98b456917..9f2e6fc754 100644 --- a/src/main/java/com/powsybl/openloadflow/ac/equations/AbstractHvdcAcEmulationFlowEquationTerm.java +++ b/src/main/java/com/powsybl/openloadflow/ac/equations/AbstractHvdcAcEmulationFlowEquationTerm.java @@ -36,6 +36,10 @@ public abstract class AbstractHvdcAcEmulationFlowEquationTerm extends AbstractNa protected LfHvdc hvdc; + protected final double lossFactor1; + + protected final double lossFactor2; + protected AbstractHvdcAcEmulationFlowEquationTerm(LfHvdc hvdc, LfBus bus1, LfBus bus2, VariableSet variableSet) { ph1Var = variableSet.getVariable(bus1.getNum(), AcVariableType.BUS_PHI); ph2Var = variableSet.getVariable(bus2.getNum(), AcVariableType.BUS_PHI); @@ -45,6 +49,8 @@ protected AbstractHvdcAcEmulationFlowEquationTerm(LfHvdc hvdc, LfBus bus1, LfBus this.hvdc = hvdc; k = hvdc.getDroop() * 180 / Math.PI; p0 = hvdc.getP0(); + lossFactor1 = hvdc.getConverterStation1().getLossFactor() / 100; + lossFactor2 = hvdc.getConverterStation2().getLossFactor() / 100; } protected double ph1() { @@ -63,6 +69,10 @@ protected double v2() { return stateVector.get(v2Var.getRow()); } + protected double getLossMultiplier() { + return (1 - lossFactor1) * (1 - lossFactor2); + } + @Override public List> getVariables() { return variables; diff --git a/src/main/java/com/powsybl/openloadflow/ac/equations/HvdcAcEmulationSide1ActiveFlowEquationTerm.java b/src/main/java/com/powsybl/openloadflow/ac/equations/HvdcAcEmulationSide1ActiveFlowEquationTerm.java index f742e8c034..005540e36f 100644 --- a/src/main/java/com/powsybl/openloadflow/ac/equations/HvdcAcEmulationSide1ActiveFlowEquationTerm.java +++ b/src/main/java/com/powsybl/openloadflow/ac/equations/HvdcAcEmulationSide1ActiveFlowEquationTerm.java @@ -18,18 +18,16 @@ */ public class HvdcAcEmulationSide1ActiveFlowEquationTerm extends AbstractHvdcAcEmulationFlowEquationTerm { - private double sign; - - private double multiplier; - public HvdcAcEmulationSide1ActiveFlowEquationTerm(LfHvdc hvdc, LfBus bus1, LfBus bus2, VariableSet variableSet) { super(hvdc, bus1, bus2, variableSet); - sign = hvdc.getConverterStation1().isRectifier() ? 1 : -1; - multiplier = 1 + sign * hvdc.getConverterStation1().getLossFactor() / 100; } private double p1() { - return multiplier * (p0 + k * (ph1() - ph2())); + return (isController() ? 1 : getLossMultiplier()) * (p0 + k * (ph1() - ph2())); + } + + private boolean isController() { + return (ph1() - ph2()) >= 0 ? true : false; } private double dp1dv1() { @@ -41,7 +39,7 @@ private double dp1dv2() { } private double dp1dph1() { - return multiplier * k; + return (isController() ? 1 : getLossMultiplier()) * k; } private double dp1dph2() { diff --git a/src/main/java/com/powsybl/openloadflow/ac/equations/HvdcAcEmulationSide2ActiveFlowEquationTerm.java b/src/main/java/com/powsybl/openloadflow/ac/equations/HvdcAcEmulationSide2ActiveFlowEquationTerm.java index 0975838cbe..acdc91e9c2 100644 --- a/src/main/java/com/powsybl/openloadflow/ac/equations/HvdcAcEmulationSide2ActiveFlowEquationTerm.java +++ b/src/main/java/com/powsybl/openloadflow/ac/equations/HvdcAcEmulationSide2ActiveFlowEquationTerm.java @@ -18,18 +18,16 @@ */ public class HvdcAcEmulationSide2ActiveFlowEquationTerm extends AbstractHvdcAcEmulationFlowEquationTerm { - private double sign; - - private double multiplier; - public HvdcAcEmulationSide2ActiveFlowEquationTerm(LfHvdc hvdc, LfBus bus1, LfBus bus2, VariableSet variableSet) { super(hvdc, bus1, bus2, variableSet); - sign = hvdc.getConverterStation2().isRectifier() ? 1 : -1; - multiplier = 1 + sign * hvdc.getConverterStation2().getLossFactor() / 100; } private double p2() { - return -multiplier * (p0 + k * (ph1() - ph2())); + return -(isController() ? 1 : getLossMultiplier()) * (p0 + k * (ph1() - ph2())); + } + + private boolean isController() { + return (ph1() - ph2()) < 0 ? true : false; } private double dp1dv1() { @@ -41,7 +39,7 @@ private double dp1dv2() { } private double dp1dph1() { - return -multiplier * k; + return -(isController() ? 1 : getLossMultiplier()) * k; } private double dp1dph2() {