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

Fix current magnitude equation for closed branch side 2 #251

Merged
merged 3 commits into from
Mar 23, 2021
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 @@ -59,22 +59,25 @@ public void update(double[] x) {
double cosPh1Ksi = FastMath.cos(ph1 + ksi);
double sinPh1Ksi = FastMath.sin(ph1 + ksi);
double theta = ksi - (a1Var != null && a1Var.isActive() ? x[a1Var.getRow()] : branch.getPiModel().getA1())
+ A2 + ph2;
+ A2 + ph2;
double sinTheta = FastMath.sin(theta);
double cosTheta = FastMath.cos(theta);

double reI1 = r1 * (w1 * (g1 * cosPh1 - b1 * sinPh1 + y * sinPh1Ksi) - w2 * sinTheta) * CURRENT_NORMALIZATION_FACTOR;
double imI1 = r1 * (w1 * (g1 * sinPh1 + b1 * cosPh1 - y * cosPh1Ksi) + w2 * cosTheta) * CURRENT_NORMALIZATION_FACTOR;
double interReI1 = g1 * cosPh1 - b1 * sinPh1 + y * sinPh1Ksi;
double interImI1 = g1 * sinPh1 + b1 * cosPh1 - y * cosPh1Ksi;

double reI1 = r1 * (w1 * interReI1 - w2 * sinTheta) * CURRENT_NORMALIZATION_FACTOR;
double imI1 = r1 * (w1 * interImI1 + w2 * cosTheta) * CURRENT_NORMALIZATION_FACTOR;
i1 = Math.hypot(reI1, imI1);

double dreI1dv1 = r1 * r1 * (g1 * cosPh1 - b1 * sinPh1 + y * sinPh1Ksi) * CURRENT_NORMALIZATION_FACTOR;
double dreI1dv1 = r1 * r1 * interReI1 * CURRENT_NORMALIZATION_FACTOR;
double dreI1dv2 = r1 * (-y * R2 * sinTheta) * CURRENT_NORMALIZATION_FACTOR;
double dreI1dph1 = r1 * w1 * (-g1 * sinPh1 - b1 * cosPh1 + y * cosPh1Ksi) * CURRENT_NORMALIZATION_FACTOR;
double dreI1dph2 = r1 * (-w2 * cosTheta) * CURRENT_NORMALIZATION_FACTOR;

double dimI1dv1 = r1 * r1 * (g1 * sinPh1 + b1 * cosPh1 - y * cosPh1Ksi) * CURRENT_NORMALIZATION_FACTOR;
double dimI1dv1 = r1 * r1 * interImI1 * CURRENT_NORMALIZATION_FACTOR;
double dimI1dv2 = r1 * (y * R2 * cosTheta) * CURRENT_NORMALIZATION_FACTOR;
double dimI1dph1 = r1 * w1 * (g1 * cosPh1 - b1 * sinPh1 + y * sinPh1Ksi) * CURRENT_NORMALIZATION_FACTOR;
double dimI1dph1 = r1 * w1 * interReI1 * CURRENT_NORMALIZATION_FACTOR;
double dimI1dph2 = r1 * (-w2 * sinTheta) * CURRENT_NORMALIZATION_FACTOR;

di1dv1 = (reI1 * dreI1dv1 + imI1 * dimI1dv1) / i1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,23 +58,26 @@ public void update(double[] x) {
double sinPh2 = FastMath.sin(ph2);
double cosPh2Ksi = FastMath.cos(ph2 + ksi);
double sinPh2Ksi = FastMath.sin(ph2 + ksi);
double theta = ksi - (a1Var != null && a1Var.isActive() ? x[a1Var.getRow()] : branch.getPiModel().getA1())
+ A2 + ph1;
double theta = ksi + (a1Var != null && a1Var.isActive() ? x[a1Var.getRow()] : branch.getPiModel().getA1())
- A2 + ph1;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should have more something like:

double theta = ksi + A1
- (a2Var != null && a2Var.isActive() ? x[a2Var.getRow()] : branch.getPiModel().getA2()) + ph1;

double sinTheta = FastMath.sin(theta);
double cosTheta = FastMath.cos(theta);

double reI2 = R2 * (w2 * (g2 * cosPh2 - b2 * sinPh2 + y * sinPh2Ksi) - w1 * sinTheta) * CURRENT_NORMALIZATION_FACTOR;
double imI2 = R2 * (w2 * (g2 * sinPh2 + b2 * cosPh2 - y * cosPh2Ksi) + w1 * cosTheta) * CURRENT_NORMALIZATION_FACTOR;
double interReI2 = g2 * cosPh2 - b2 * sinPh2 + y * sinPh2Ksi;
double interImI2 = g2 * sinPh2 + b2 * cosPh2 - y * cosPh2Ksi;

double reI2 = R2 * (w2 * interReI2 - w1 * sinTheta) * CURRENT_NORMALIZATION_FACTOR;
double imI2 = R2 * (w2 * interImI2 + w1 * cosTheta) * CURRENT_NORMALIZATION_FACTOR;
i2 = Math.hypot(reI2, imI2);

double dreI2dv2 = R2 * R2 * (g2 * cosPh2 - b2 * sinPh2 + y * sinPh2Ksi) * CURRENT_NORMALIZATION_FACTOR;
double dreI2dv2 = R2 * R2 * interReI2 * CURRENT_NORMALIZATION_FACTOR;
double dreI2dv1 = R2 * (-y * r1 * sinTheta) * CURRENT_NORMALIZATION_FACTOR;
double dreI2dph2 = R2 * w2 * (-g2 * sinPh2 - b2 * cosPh2 + y * cosPh2Ksi) * CURRENT_NORMALIZATION_FACTOR;
double dreI2dph1 = R2 * (-w1 * cosTheta) * CURRENT_NORMALIZATION_FACTOR;

double dimI2dv2 = R2 * R2 * (g2 * sinPh2 + b2 * cosPh2 - y * cosPh2Ksi) * CURRENT_NORMALIZATION_FACTOR;
double dimI2dv2 = R2 * R2 * interImI2 * CURRENT_NORMALIZATION_FACTOR;
double dimI2dv1 = R2 * (y * r1 * cosTheta) * CURRENT_NORMALIZATION_FACTOR;
double dimI2dph2 = R2 * w2 * (g2 * cosPh2 - b2 * sinPh2 + y * sinPh2Ksi) * CURRENT_NORMALIZATION_FACTOR;
double dimI2dph2 = R2 * w2 * interReI2 * CURRENT_NORMALIZATION_FACTOR;
double dimI2dph1 = R2 * (-w1 * sinTheta) * CURRENT_NORMALIZATION_FACTOR;

di2dv2 = (reI2 * dreI2dv2 + imI2 * dimI2dv2) / i2;
Expand Down