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

Assert active power, reactive power and current consistency #545

Merged
merged 2 commits into from
Jun 7, 2022
Merged
Changes from 1 commit
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
23 changes: 23 additions & 0 deletions src/test/java/com/powsybl/openloadflow/ac/AcEquationsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.util.List;

import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;

/**
* @author Geoffroy Jamgotchian <geoffroy.jamgotchian at rte-france.com>
Expand Down Expand Up @@ -141,6 +142,28 @@ void branchTest() {
assertArrayEquals(new double[] {0.3420075216110214, Double.NaN, Double.NaN, 0.31907275662806295, Double.NaN, Double.NaN, Double.NaN},
eval(new OpenBranchSide2CurrentMagnitudeEquationTerm(branch, bus2, variableSet, false, false), variables, sv));

// assert current equation is consistent with active and reactive power ones
var p1Eq = new ClosedBranchSide1ActiveFlowEquationTerm(branch, bus1, bus2, variableSet, true, true);
p1Eq.setStateVector(sv);
double p1 = p1Eq.eval();
var q1Eq = new ClosedBranchSide1ReactiveFlowEquationTerm(branch, bus1, bus2, variableSet, true, true);
q1Eq.setStateVector(sv);
double q1 = q1Eq.eval();
var i1Eq = new ClosedBranchSide1CurrentMagnitudeEquationTerm(branch, bus1, bus2, variableSet, true, true);
i1Eq.setStateVector(sv);
double i1 = i1Eq.eval();
assertEquals(i1, Math.hypot(p1, q1) / V_1, 10e-14);
Copy link
Member Author

Choose a reason for hiding this comment

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

@annetill is it normal to not have the sqrt(3) here ?

Copy link
Member

Choose a reason for hiding this comment

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

After looking at the code, yes it is normal. The sqrt(3) is managed by function PerUnit.ib() for sensitivity and security analysis.

Copy link
Member Author

Choose a reason for hiding this comment

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

It doesn't mean it is correct. As far as I understand main principle of peruniting is to perunit only 2 quantities (for us it is apparent power and voltage) and all the other quantities are calculated from the 2 chosen ones.
So for me, the values in per unit are not correct even if one in SI are correct.

Copy link
Member Author

@geofjamg geofjamg Jun 7, 2022

Choose a reason for hiding this comment

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

According to https://en.wikipedia.org/wiki/Per-unit_system it seems correct


var p2Eq = new ClosedBranchSide2ActiveFlowEquationTerm(branch, bus1, bus2, variableSet, true, true);
p2Eq.setStateVector(sv);
double p2 = p2Eq.eval();
var q2Eq = new ClosedBranchSide2ReactiveFlowEquationTerm(branch, bus1, bus2, variableSet, true, true);
q2Eq.setStateVector(sv);
double q2 = q2Eq.eval();
var i2Eq = new ClosedBranchSide2CurrentMagnitudeEquationTerm(branch, bus1, bus2, variableSet, true, true);
i2Eq.setStateVector(sv);
double i2 = i2Eq.eval();
assertEquals(i2, Math.hypot(p2, q2) / V_2, 10e-14);
}

@Test
Expand Down