Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make some equation term methods public #934

Merged
merged 2 commits into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ public abstract class AbstractClosedBranchAcFlowEquationTerm extends AbstractBra

protected final List<Variable<AcVariableType>> 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;
case ZERO -> AcVariableType.BUS_V_ZERO;
};
}

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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,24 +29,24 @@ 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
+ di1dv2(y, ksi, g1, b1, v1, ph1, r1, a1, v2, ph2) * 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;
}
Expand Down Expand Up @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,24 +29,24 @@ 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
+ di2dv2(y, ksi, g2, b2, v1, ph1, r1, a1, v2, ph2) * 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;
}
Expand Down Expand Up @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
Loading
Loading