From 4f6df0a6fb261e939db31373f0ecf15f4dcead04 Mon Sep 17 00:00:00 2001 From: Geoffroy Jamgotchian Date: Wed, 13 Dec 2023 22:30:31 +0100 Subject: [PATCH] Make some equation term methods public Signed-off-by: Geoffroy Jamgotchian --- ...bstractClosedBranchAcFlowEquationTerm.java | 4 +-- .../ClosedBranchI1xFlowEquationTerm.java | 6 ++--- ...osedBranchSide1ActiveFlowEquationTerm.java | 13 ++++++---- ...anchSide1CurrentMagnitudeEquationTerm.java | 26 +++++++++---------- ...edBranchSide1ReactiveFlowEquationTerm.java | 14 ++++++---- ...osedBranchSide2ActiveFlowEquationTerm.java | 14 ++++++---- ...anchSide2CurrentMagnitudeEquationTerm.java | 26 +++++++++---------- ...edBranchSide2ReactiveFlowEquationTerm.java | 14 ++++++---- ...anchSide1CurrentMagnitudeEquationTerm.java | 2 +- ...anchSide2CurrentMagnitudeEquationTerm.java | 2 +- ...huntCompensatorActiveFlowEquationTerm.java | 4 +-- ...ntCompensatorReactiveFlowEquationTerm.java | 12 ++++++--- 12 files changed, 78 insertions(+), 59 deletions(-) diff --git a/src/main/java/com/powsybl/openloadflow/ac/equations/AbstractClosedBranchAcFlowEquationTerm.java b/src/main/java/com/powsybl/openloadflow/ac/equations/AbstractClosedBranchAcFlowEquationTerm.java index d5d401a17d..c7f2f61402 100644 --- a/src/main/java/com/powsybl/openloadflow/ac/equations/AbstractClosedBranchAcFlowEquationTerm.java +++ b/src/main/java/com/powsybl/openloadflow/ac/equations/AbstractClosedBranchAcFlowEquationTerm.java @@ -38,7 +38,7 @@ public abstract class AbstractClosedBranchAcFlowEquationTerm extends AbstractBra protected final List> variables = new ArrayList<>(); - private static AcVariableType getVoltageMagnitudeType(Fortescue.SequenceType sequenceType) { + public static AcVariableType getVoltageMagnitudeType(Fortescue.SequenceType sequenceType) { return switch (sequenceType) { case POSITIVE -> AcVariableType.BUS_V; case NEGATIVE -> AcVariableType.BUS_V_NEGATIVE; @@ -46,7 +46,7 @@ private static AcVariableType getVoltageMagnitudeType(Fortescue.SequenceType seq }; } - private static AcVariableType getVoltageAngleType(Fortescue.SequenceType sequenceType) { + public static AcVariableType getVoltageAngleType(Fortescue.SequenceType sequenceType) { return switch (sequenceType) { case POSITIVE -> AcVariableType.BUS_PHI; case NEGATIVE -> AcVariableType.BUS_PHI_NEGATIVE; diff --git a/src/main/java/com/powsybl/openloadflow/ac/equations/ClosedBranchI1xFlowEquationTerm.java b/src/main/java/com/powsybl/openloadflow/ac/equations/ClosedBranchI1xFlowEquationTerm.java index 1135abca3b..c9fea8a908 100644 --- a/src/main/java/com/powsybl/openloadflow/ac/equations/ClosedBranchI1xFlowEquationTerm.java +++ b/src/main/java/com/powsybl/openloadflow/ac/equations/ClosedBranchI1xFlowEquationTerm.java @@ -43,15 +43,15 @@ public static double i1x(double g1, double b1, double v1, double ph1, double v2, return (g1 + g12) * v1 * FastMath.cos(ph1) - (b1 + b12) * v1 * FastMath.sin(ph1) - g12 * v2 * FastMath.cos(ph2) + b12 * v2 * FastMath.sin(ph2); } - private static double di1xdv1(double g1, double b1, double ph1, double g12, double b12) { + public static double di1xdv1(double g1, double b1, double ph1, double g12, double b12) { return (g1 + g12) * FastMath.cos(ph1) - (b1 + b12) * FastMath.sin(ph1); } - private static double di1xdv2(double ph2, double g12, double b12) { + public static double di1xdv2(double ph2, double g12, double b12) { return -g12 * FastMath.cos(ph2) + b12 * FastMath.sin(ph2); } - private static double di1xdph1(double g1, double b1, double v1, double ph1, double g12, double b12) { + public static double di1xdph1(double g1, double b1, double v1, double ph1, double g12, double b12) { return -(g1 + g12) * v1 * FastMath.sin(ph1) - (b1 + b12) * v1 * FastMath.cos(ph1); } diff --git a/src/main/java/com/powsybl/openloadflow/ac/equations/ClosedBranchSide1ActiveFlowEquationTerm.java b/src/main/java/com/powsybl/openloadflow/ac/equations/ClosedBranchSide1ActiveFlowEquationTerm.java index d7e08ca128..5d847fa7e5 100644 --- a/src/main/java/com/powsybl/openloadflow/ac/equations/ClosedBranchSide1ActiveFlowEquationTerm.java +++ b/src/main/java/com/powsybl/openloadflow/ac/equations/ClosedBranchSide1ActiveFlowEquationTerm.java @@ -33,11 +33,10 @@ public ClosedBranchSide1ActiveFlowEquationTerm(LfBranch branch, LfBus bus1, LfBu super(branch, bus1, bus2, variableSet, deriveA1, deriveR1, sequenceType); } - protected double calculateSensi(double dph1, double dph2, double dv1, double dv2, double da1, double dr1) { - double v1 = v1(); - double r1 = r1(); - double v2 = v2(); - double theta = theta1(ksi, ph1(), a1(), ph2()); + public static double calculateSensi(double g1, double y, double ksi, + double v1, double ph1, double a1, double r1, double v2, double ph2, + double dph1, double dph2, double dv1, double dv2, double da1, double dr1) { + double theta = theta1(ksi, ph1, a1, ph2); double cosTheta = FastMath.cos(theta); double sinTheta = FastMath.sin(theta); double sinKsi = FastMath.sin(ksi); @@ -49,6 +48,10 @@ protected double calculateSensi(double dph1, double dph2, double dv1, double dv2 + dp1dr1(y, sinKsi, g1, v1, r1, v2, sinTheta) * dr1; } + protected double calculateSensi(double dph1, double dph2, double dv1, double dv2, double da1, double dr1) { + return calculateSensi(g1, y, ksi, v1(), ph1(), a1(), r1(), v2(), ph2(), dph1, dph2, dv1, dv2, da1, dr1); + } + public static double p1(double y, double sinKsi, double g1, double v1, double r1, double v2, double sinTheta) { return r1 * v1 * (g1 * r1 * v1 + y * r1 * v1 * sinKsi - y * R2 * v2 * sinTheta); } diff --git a/src/main/java/com/powsybl/openloadflow/ac/equations/ClosedBranchSide1CurrentMagnitudeEquationTerm.java b/src/main/java/com/powsybl/openloadflow/ac/equations/ClosedBranchSide1CurrentMagnitudeEquationTerm.java index 34d30c02ff..592a8dbe3c 100644 --- a/src/main/java/com/powsybl/openloadflow/ac/equations/ClosedBranchSide1CurrentMagnitudeEquationTerm.java +++ b/src/main/java/com/powsybl/openloadflow/ac/equations/ClosedBranchSide1CurrentMagnitudeEquationTerm.java @@ -29,17 +29,12 @@ public ClosedBranchSide1CurrentMagnitudeEquationTerm(LfBranch branch, LfBus bus1 super(branch, bus1, bus2, variableSet, deriveA1, deriveR1, Fortescue.SequenceType.POSITIVE); } - @Override - protected double calculateSensi(double dph1, double dph2, double dv1, double dv2, double da1, double dr1) { + public static double calculateSensi(double y, double ksi, double g1, double b1, + double v1, double ph1, double r1, double a1, double v2, double ph2, + double dph1, double dph2, double dv1, double dv2, double da1, double dr1) { if (dr1 != 0) { throw new IllegalArgumentException("Derivative with respect to r1 not implemented"); } - double v1 = v1(); - double ph1 = ph1(); - double r1 = r1(); - double a1 = a1(); - double v2 = v2(); - double ph2 = ph2(); return di1dph1(y, ksi, g1, b1, v1, ph1, r1, a1, v2, ph2) * dph1 + di1dph2(y, ksi, g1, b1, v1, ph1, r1, a1, v2, ph2) * dph2 + di1dv1(y, ksi, g1, b1, v1, ph1, r1, a1, v2, ph2) * dv1 @@ -47,6 +42,11 @@ protected double calculateSensi(double dph1, double dph2, double dv1, double dv2 + di1da1(y, ksi, g1, b1, v1, ph1, r1, a1, v2, ph2) * da1; } + @Override + protected double calculateSensi(double dph1, double dph2, double dv1, double dv2, double da1, double dr1) { + return calculateSensi(y, ksi, g1, b1, v1(), ph1(), r1(), a1(), v2(), ph2(), dph1, dph2, dv1, dv2, da1, dr1); + } + private static double theta(double ksi, double a1, double ph2) { return ksi - a1 + A2 + ph2; } @@ -108,27 +108,27 @@ private static double dimI1dph2(double y, double ksi, double r1, double a1, doub return r1 * (-y * R2 * v2 * FastMath.sin(theta(ksi, a1, ph2))); } - private static double di1dv1(double y, double ksi, double g1, double b1, double v1, double ph1, double r1, double a1, double v2, double ph2) { + public static double di1dv1(double y, double ksi, double g1, double b1, double v1, double ph1, double r1, double a1, double v2, double ph2) { double theta = theta(ksi, a1, ph2); return (reI1(y, ksi, g1, b1, v1, ph1, r1, v2, theta) * dreI1dv1(y, ksi, g1, b1, ph1, r1) + imI1(y, ksi, g1, b1, v1, ph1, r1, v2, theta) * dimI1dv1(y, ksi, g1, b1, ph1, r1)) / i1(y, ksi, g1, b1, v1, ph1, r1, v2, theta); } - private static double di1dv2(double y, double ksi, double g1, double b1, double v1, double ph1, double r1, double a1, double v2, double ph2) { + public static double di1dv2(double y, double ksi, double g1, double b1, double v1, double ph1, double r1, double a1, double v2, double ph2) { double theta = theta(ksi, a1, ph2); return (reI1(y, ksi, g1, b1, v1, ph1, r1, v2, theta) * dreI1dv2(y, ksi, r1, a1, ph2) + imI1(y, ksi, g1, b1, v1, ph1, r1, v2, theta) * dimI1dv2(y, ksi, r1, a1, ph2)) / i1(y, ksi, g1, b1, v1, ph1, r1, v2, theta); } - private static double di1dph1(double y, double ksi, double g1, double b1, double v1, double ph1, double r1, double a1, double v2, double ph2) { + public static double di1dph1(double y, double ksi, double g1, double b1, double v1, double ph1, double r1, double a1, double v2, double ph2) { double theta = theta(ksi, a1, ph2); return (reI1(y, ksi, g1, b1, v1, ph1, r1, v2, theta) * dreI1dph1(y, ksi, g1, b1, v1, ph1, r1) + imI1(y, ksi, g1, b1, v1, ph1, r1, v2, theta) * dimI1dph1(y, ksi, g1, b1, v1, ph1, r1)) / i1(y, ksi, g1, b1, v1, ph1, r1, v2, theta); } - private static double di1dph2(double y, double ksi, double g1, double b1, double v1, double ph1, double r1, double a1, double v2, double ph2) { + public static double di1dph2(double y, double ksi, double g1, double b1, double v1, double ph1, double r1, double a1, double v2, double ph2) { double theta = theta(ksi, a1, ph2); return (reI1(y, ksi, g1, b1, v1, ph1, r1, v2, theta) * dreI1dph2(y, ksi, r1, a1, v2, ph2) + imI1(y, ksi, g1, b1, v1, ph1, r1, v2, theta) * dimI1dph2(y, ksi, r1, a1, v2, ph2)) / i1(y, ksi, g1, b1, v1, ph1, r1, v2, theta); } - private static double di1da1(double y, double ksi, double g1, double b1, double v1, double ph1, double r1, double a1, double v2, double ph2) { + public static double di1da1(double y, double ksi, double g1, double b1, double v1, double ph1, double r1, double a1, double v2, double ph2) { return -di1dph2(y, ksi, g1, b1, v1, ph1, r1, a1, v2, ph2); } diff --git a/src/main/java/com/powsybl/openloadflow/ac/equations/ClosedBranchSide1ReactiveFlowEquationTerm.java b/src/main/java/com/powsybl/openloadflow/ac/equations/ClosedBranchSide1ReactiveFlowEquationTerm.java index d72fe38c7c..8c41893735 100644 --- a/src/main/java/com/powsybl/openloadflow/ac/equations/ClosedBranchSide1ReactiveFlowEquationTerm.java +++ b/src/main/java/com/powsybl/openloadflow/ac/equations/ClosedBranchSide1ReactiveFlowEquationTerm.java @@ -33,11 +33,10 @@ public ClosedBranchSide1ReactiveFlowEquationTerm(LfBranch branch, LfBus bus1, Lf super(branch, bus1, bus2, variableSet, deriveA1, deriveR1, sequenceType); } - protected double calculateSensi(double dph1, double dph2, double dv1, double dv2, double da1, double dr1) { - double v1 = v1(); - double r1 = r1(); - double v2 = v2(); - double theta = theta1(ksi, ph1(), a1(), ph2()); + public static double calculateSensi(double y, double ksi, double b1, + double v1, double ph1, double r1, double a1, double v2, double ph2, + double dph1, double dph2, double dv1, double dv2, double da1, double dr1) { + double theta = theta1(ksi, ph1, a1, ph2); double cosTheta = FastMath.cos(theta); double sinTheta = FastMath.sin(theta); double cosKsi = FastMath.cos(ksi); @@ -49,6 +48,11 @@ protected double calculateSensi(double dph1, double dph2, double dv1, double dv2 + dq1dr1(y, cosKsi, b1, v1, r1, v2, cosTheta) * dr1; } + @Override + protected double calculateSensi(double dph1, double dph2, double dv1, double dv2, double da1, double dr1) { + return calculateSensi(y, ksi, b1, v1(), ph1(), r1(), a1(), v2(), ph2(), dph1, dph2, dv1, dv2, da1, dr1); + } + public static double q1(double y, double cosKsi, double b1, double v1, double r1, double v2, double cosTheta) { return r1 * v1 * (-b1 * r1 * v1 + y * r1 * v1 * cosKsi - y * R2 * v2 * cosTheta); diff --git a/src/main/java/com/powsybl/openloadflow/ac/equations/ClosedBranchSide2ActiveFlowEquationTerm.java b/src/main/java/com/powsybl/openloadflow/ac/equations/ClosedBranchSide2ActiveFlowEquationTerm.java index 2dd4c5b5b5..50973d3eb6 100644 --- a/src/main/java/com/powsybl/openloadflow/ac/equations/ClosedBranchSide2ActiveFlowEquationTerm.java +++ b/src/main/java/com/powsybl/openloadflow/ac/equations/ClosedBranchSide2ActiveFlowEquationTerm.java @@ -33,11 +33,10 @@ public ClosedBranchSide2ActiveFlowEquationTerm(LfBranch branch, LfBus bus1, LfBu super(branch, bus1, bus2, variableSet, deriveA1, deriveR1, sequenceType); } - protected double calculateSensi(double dph1, double dph2, double dv1, double dv2, double da1, double dr1) { - double v1 = v1(); - double r1 = r1(); - double v2 = v2(); - double theta = theta2(ksi, ph1(), a1(), ph2()); + public static double calculateSensi(double y, double ksi, double g2, + double v1, double ph1, double r1, double a1, double v2, double ph2, + double dph1, double dph2, double dv1, double dv2, double da1, double dr1) { + double theta = theta2(ksi, ph1, a1, ph2); double cosTheta = FastMath.cos(theta); double sinTheta = FastMath.sin(theta); return dp2dph1(y, v1, r1, v2, cosTheta) * dph1 @@ -48,6 +47,11 @@ protected double calculateSensi(double dph1, double dph2, double dv1, double dv2 + dp2dr1(y, v1, v2, sinTheta) * dr1; } + @Override + protected double calculateSensi(double dph1, double dph2, double dv1, double dv2, double da1, double dr1) { + return calculateSensi(y, ksi, g2, v1(), ph1(), r1(), a1(), v2(), ph2(), dph1, dph2, dv1, dv2, da1, dr1); + } + public static double p2(double y, double sinKsi, double g2, double v1, double r1, double v2, double sinTheta) { return R2 * v2 * (g2 * R2 * v2 - y * r1 * v1 * sinTheta + y * R2 * v2 * sinKsi); } diff --git a/src/main/java/com/powsybl/openloadflow/ac/equations/ClosedBranchSide2CurrentMagnitudeEquationTerm.java b/src/main/java/com/powsybl/openloadflow/ac/equations/ClosedBranchSide2CurrentMagnitudeEquationTerm.java index 10ff518c9b..66c009fe4e 100644 --- a/src/main/java/com/powsybl/openloadflow/ac/equations/ClosedBranchSide2CurrentMagnitudeEquationTerm.java +++ b/src/main/java/com/powsybl/openloadflow/ac/equations/ClosedBranchSide2CurrentMagnitudeEquationTerm.java @@ -29,17 +29,12 @@ public ClosedBranchSide2CurrentMagnitudeEquationTerm(LfBranch branch, LfBus bus1 super(branch, bus1, bus2, variableSet, deriveA1, deriveR1, Fortescue.SequenceType.POSITIVE); } - @Override - protected double calculateSensi(double dph1, double dph2, double dv1, double dv2, double da1, double dr1) { + public static double calculateSensi(double y, double ksi, double g2, double b2, + double v1, double ph1, double r1, double a1, double v2, double ph2, + double dph1, double dph2, double dv1, double dv2, double da1, double dr1) { if (dr1 != 0) { throw new IllegalArgumentException("Derivative with respect to r1 not implemented"); } - double v1 = v1(); - double ph1 = ph1(); - double r1 = r1(); - double a1 = a1(); - double v2 = v2(); - double ph2 = ph2(); return di2dph1(y, ksi, g2, b2, v1, ph1, r1, a1, v2, ph2) * dph1 + di2dph2(y, ksi, g2, b2, v1, ph1, r1, a1, v2, ph2) * dph2 + di2dv1(y, ksi, g2, b2, v1, ph1, r1, a1, v2, ph2) * dv1 @@ -47,6 +42,11 @@ protected double calculateSensi(double dph1, double dph2, double dv1, double dv2 + di2da1(y, ksi, g2, b2, v1, ph1, r1, a1, v2, ph2) * da1; } + @Override + protected double calculateSensi(double dph1, double dph2, double dv1, double dv2, double da1, double dr1) { + return calculateSensi(y, ksi, g2, b2, v1(), ph1(), r1(), a1(), v2(), ph2(), dph1, dph2, dv1, dv2, da1, dr1); + } + private static double theta(double ksi, double ph1, double a1) { return ksi + a1 - A2 + ph1; } @@ -108,27 +108,27 @@ private static double dimI2dph1(double y, double v1, double r1, double theta) { return R2 * (-y * r1 * v1 * FastMath.sin(theta)); } - private static double di2dv2(double y, double ksi, double g2, double b2, double v1, double ph1, double r1, double a1, double v2, double ph2) { + public static double di2dv2(double y, double ksi, double g2, double b2, double v1, double ph1, double r1, double a1, double v2, double ph2) { double theta = theta(ksi, ph1, a1); return (reI2(y, ksi, g2, b2, v1, r1, v2, ph2, theta) * dreI2dv2(y, ksi, g2, b2, ph2) + imI2(y, ksi, g2, b2, v1, r1, v2, ph2, theta) * dimI2dv2(y, ksi, g2, b2, ph2)) / i2(y, ksi, g2, b2, v1, r1, v2, ph2, theta); } - private static double di2dv1(double y, double ksi, double g2, double b2, double v1, double ph1, double r1, double a1, double v2, double ph2) { + public static double di2dv1(double y, double ksi, double g2, double b2, double v1, double ph1, double r1, double a1, double v2, double ph2) { double theta = theta(ksi, ph1, a1); return (reI2(y, ksi, g2, b2, v1, r1, v2, ph2, theta) * dreI2dv1(y, r1, theta) + imI2(y, ksi, g2, b2, v1, r1, v2, ph2, theta) * dimI2dv1(y, ksi, ph1, r1, a1)) / i2(y, ksi, g2, b2, v1, r1, v2, ph2, theta); } - private static double di2dph2(double y, double ksi, double g2, double b2, double v1, double ph1, double r1, double a1, double v2, double ph2) { + public static double di2dph2(double y, double ksi, double g2, double b2, double v1, double ph1, double r1, double a1, double v2, double ph2) { double theta = theta(ksi, ph1, a1); return (reI2(y, ksi, g2, b2, v1, r1, v2, ph2, theta) * dreI2dph2(y, ksi, g2, b2, v2, ph2) + imI2(y, ksi, g2, b2, v1, r1, v2, ph2, theta) * dimI2dph2(y, ksi, g2, b2, v2, ph2)) / i2(y, ksi, g2, b2, v1, r1, v2, ph2, theta); } - private static double di2dph1(double y, double ksi, double g2, double b2, double v1, double ph1, double r1, double a1, double v2, double ph2) { + public static double di2dph1(double y, double ksi, double g2, double b2, double v1, double ph1, double r1, double a1, double v2, double ph2) { double theta = theta(ksi, ph1, a1); return (reI2(y, ksi, g2, b2, v1, r1, v2, ph2, theta) * dreI2dph1(y, ksi, v1, ph1, r1, a1) + imI2(y, ksi, g2, b2, v1, r1, v2, ph2, theta) * dimI2dph1(y, v1, r1, theta)) / i2(y, ksi, g2, b2, v1, r1, v2, ph2, theta); } - private static double di2da1(double y, double ksi, double g2, double b2, double v1, double ph1, double r1, double a1, double v2, double ph2) { + public static double di2da1(double y, double ksi, double g2, double b2, double v1, double ph1, double r1, double a1, double v2, double ph2) { return di2dph1(y, ksi, g2, b2, v1, ph1, r1, a1, v2, ph2); } diff --git a/src/main/java/com/powsybl/openloadflow/ac/equations/ClosedBranchSide2ReactiveFlowEquationTerm.java b/src/main/java/com/powsybl/openloadflow/ac/equations/ClosedBranchSide2ReactiveFlowEquationTerm.java index 46bffea34a..731ceaa511 100644 --- a/src/main/java/com/powsybl/openloadflow/ac/equations/ClosedBranchSide2ReactiveFlowEquationTerm.java +++ b/src/main/java/com/powsybl/openloadflow/ac/equations/ClosedBranchSide2ReactiveFlowEquationTerm.java @@ -33,11 +33,10 @@ public ClosedBranchSide2ReactiveFlowEquationTerm(LfBranch branch, LfBus bus1, Lf super(branch, bus1, bus2, variableSet, deriveA1, deriveR1, sequenceType); } - protected double calculateSensi(double dph1, double dph2, double dv1, double dv2, double da1, double dr1) { - double v1 = v1(); - double r1 = r1(); - double v2 = v2(); - double theta = theta2(ksi, ph1(), a1(), ph2()); + public static double calculateSensi(double y, double ksi, double b2, + double v1, double ph1, double r1, double a1, double v2, double ph2, + double dph1, double dph2, double dv1, double dv2, double da1, double dr1) { + double theta = theta2(ksi, ph1, a1, ph2); double cosTheta = FastMath.cos(theta); double sinTheta = FastMath.sin(theta); return dq2dph1(y, v1, r1, v2, sinTheta) * dph1 @@ -48,6 +47,11 @@ protected double calculateSensi(double dph1, double dph2, double dv1, double dv2 + dq2dr1(y, v1, v2, cosTheta) * dr1; } + @Override + protected double calculateSensi(double dph1, double dph2, double dv1, double dv2, double da1, double dr1) { + return calculateSensi(y, ksi, b2, v1(), ph1(), r1(), a1(), v2(), ph2(), dph1, dph2, dv1, dv2, da1, dr1); + } + public static double q2(double y, double cosKsi, double b2, double v1, double r1, double v2, double cosTheta) { return R2 * v2 * (-b2 * R2 * v2 - y * r1 * v1 * cosTheta + y * R2 * v2 * cosKsi); } diff --git a/src/main/java/com/powsybl/openloadflow/ac/equations/OpenBranchSide1CurrentMagnitudeEquationTerm.java b/src/main/java/com/powsybl/openloadflow/ac/equations/OpenBranchSide1CurrentMagnitudeEquationTerm.java index 4181ed31a9..a1421030b3 100644 --- a/src/main/java/com/powsybl/openloadflow/ac/equations/OpenBranchSide1CurrentMagnitudeEquationTerm.java +++ b/src/main/java/com/powsybl/openloadflow/ac/equations/OpenBranchSide1CurrentMagnitudeEquationTerm.java @@ -72,7 +72,7 @@ private static double dimI2dv2(double y, double cosKsi, double sinKsi, double g1 return R2 * R2 * (gres(y, sinKsi, g1, b1, g2, shunt) * FastMath.sin(ph2) + bres(y, cosKsi, g1, b1, b2, shunt) * FastMath.cos(ph2)); } - private static double di2dv2(double y, double cosKsi, double sinKsi, double g1, double b1, double g2, double b2, double v2, double ph2) { + public static double di2dv2(double y, double cosKsi, double sinKsi, double g1, double b1, double g2, double b2, double v2, double ph2) { return (reI2(y, cosKsi, sinKsi, g1, b1, g2, b2, v2, ph2) * dreI2dv2(y, cosKsi, sinKsi, g1, b1, g2, b2, ph2) + imI2(y, cosKsi, sinKsi, g1, b1, g2, b2, v2, ph2) * dimI2dv2(y, cosKsi, sinKsi, g1, b1, g2, b2, ph2)) / i2(y, cosKsi, sinKsi, g1, b1, g2, b2, v2, ph2); } diff --git a/src/main/java/com/powsybl/openloadflow/ac/equations/OpenBranchSide2CurrentMagnitudeEquationTerm.java b/src/main/java/com/powsybl/openloadflow/ac/equations/OpenBranchSide2CurrentMagnitudeEquationTerm.java index 95c12ca9e8..8bef4434e2 100644 --- a/src/main/java/com/powsybl/openloadflow/ac/equations/OpenBranchSide2CurrentMagnitudeEquationTerm.java +++ b/src/main/java/com/powsybl/openloadflow/ac/equations/OpenBranchSide2CurrentMagnitudeEquationTerm.java @@ -80,7 +80,7 @@ private static double dimI1dv1(double y, double cosKsi, double sinKsi, double g1 return r1 * r1 * (gres(y, sinKsi, g1, g2, b2, shunt) * FastMath.sin(ph1) + bres(y, cosKsi, b1, g2, b2, shunt) * FastMath.cos(ph1)); } - private static double di1dv1(double y, double cosKsi, double sinKsi, double g1, double b1, double g2, double b2, double v1, double ph1, double r1) { + public static double di1dv1(double y, double cosKsi, double sinKsi, double g1, double b1, double g2, double b2, double v1, double ph1, double r1) { return (reI1(y, cosKsi, sinKsi, g1, b1, g2, b2, v1, ph1, r1) * dreI1dv1(y, cosKsi, sinKsi, g1, b1, g2, b2, ph1, r1) + imI1(y, cosKsi, sinKsi, g1, b1, g2, b2, v1, ph1, r1) * dimI1dv1(y, cosKsi, sinKsi, g1, b1, g2, b2, ph1, r1)) / i1(y, cosKsi, sinKsi, g1, b1, g2, b2, v1, ph1, r1); } diff --git a/src/main/java/com/powsybl/openloadflow/ac/equations/ShuntCompensatorActiveFlowEquationTerm.java b/src/main/java/com/powsybl/openloadflow/ac/equations/ShuntCompensatorActiveFlowEquationTerm.java index cb67318696..39d5b8705e 100644 --- a/src/main/java/com/powsybl/openloadflow/ac/equations/ShuntCompensatorActiveFlowEquationTerm.java +++ b/src/main/java/com/powsybl/openloadflow/ac/equations/ShuntCompensatorActiveFlowEquationTerm.java @@ -35,11 +35,11 @@ private double g() { return element.getG(); } - private static double p(double v, double g) { + public static double p(double v, double g) { return g * v * v; } - private static double dpdv(double v, double g) { + public static double dpdv(double v, double g) { return 2 * g * v; } diff --git a/src/main/java/com/powsybl/openloadflow/ac/equations/ShuntCompensatorReactiveFlowEquationTerm.java b/src/main/java/com/powsybl/openloadflow/ac/equations/ShuntCompensatorReactiveFlowEquationTerm.java index 7767145834..ac81d3b5dc 100644 --- a/src/main/java/com/powsybl/openloadflow/ac/equations/ShuntCompensatorReactiveFlowEquationTerm.java +++ b/src/main/java/com/powsybl/openloadflow/ac/equations/ShuntCompensatorReactiveFlowEquationTerm.java @@ -43,15 +43,15 @@ private double b() { return bVar != null ? sv.get(bVar.getRow()) : element.getB(); } - private static double q(double v, double b) { + public static double q(double v, double b) { return -b * v * v; } - private static double dqdv(double v, double b) { + public static double dqdv(double v, double b) { return -2 * b * v; } - private static double dqdb(double v) { + public static double dqdb(double v) { return -v * v; } @@ -72,13 +72,17 @@ public double der(Variable variable) { } } + public static double calculateSensi(double v, double b, double dv, double db) { + return dqdv(v, b) * dv + dqdb(v) * db; + } + @Override public double calculateSensi(DenseMatrix dx, int column) { double dv = dx.get(vVar.getRow(), column); double db = bVar != null ? dx.get(bVar.getRow(), column) : 0; double v = v(); double b = b(); - return dqdv(v, b) * dv + dqdb(v) * db; + return calculateSensi(v, b, dv, db); } @Override