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

Add sensitivities on intensity #231

Merged
merged 25 commits into from
Mar 17, 2021
Merged

Add sensitivities on intensity #231

merged 25 commits into from
Mar 17, 2021

Conversation

Djazouli
Copy link
Contributor

Signed-off-by: Gael Macherel gael.macherel@artelys.com

Please check if the PR fulfills these requirements (please use '[x]' to check the checkboxes, or submit the PR and then click the checkboxes)

  • The commit message follows our guidelines
  • [] Tests for the changes have been added (for bug fixes / features)
  • [] Docs have been added / updated (for bug fixes / features)


if (i2 != null) {
Equation i = equationSystem.createEquation(bus2.getNum(), EquationType.BUS_I).addTerm(i2);
i.setActive(false); // equation is set to inactive so it does not appear in jacobian
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is certainly not the proper way to do this

assertEquals(5, result.getSensitivityValues().size());
// todo: Remove the *100 from assert. Currently the
// todo: loadflow from OLF and Hades provides different results
assertEquals(766.4654d, getFunctionReference(result, "l23"), LoadFlowAssert.DELTA_I * 100);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Those *100 are needed because of a difference I have between Hades loadflow and Openloadflow loadflow. But maybe this is juste my hades2 config that is wrong ?

@@ -23,6 +23,7 @@
public static final double DELTA_ANGLE = 1E-6d;
public static final double DELTA_V = 1E-3d;
public static final double DELTA_POWER = 1E-3d;
public static final double DELTA_I = 1E-2d;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

10e-3 would be better, but as I said before, I have some trouble mapping the Hades2 loadflow with the OpenLoadFlow loadflow to check my results, even on a very small network (4 buses, 1 transfo)

Base automatically changed from sensi_ac to master February 28, 2021 13:36
Signed-off-by: Gael Macherel <gael.macherel@artelys.com>
@Djazouli Djazouli force-pushed the intensity_from_ac branch from a54456a to fd4b83f Compare March 1, 2021 14:23
double p1 = r1 * v1 * (g1 * r1 * v1 + y * r1 * v1 * sinKsi - y * R2 * v2 * sinTheta);
double q1 = r1 * v1 * (-b1 * r1 * v1 + y * r1 * v1 * cosKsi - y * R2 * v2 * cosTheta);

i1 = Math.hypot(p1, q1) / (Math.sqrt(3.) * v1 / 1000);
Copy link
Member

Choose a reason for hiding this comment

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

@Hadrien-Godard @Djazouli I think we don't have to compute the intensity from p and q. I have done that before as it was a post-processing. Can we compute the intensity through the Ohm law ?

Copy link
Member

Choose a reason for hiding this comment

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

Yes we can, but we will end up with the same formula since Ohm law is used to obtain above expression of p and q from v and phi.
The difficulty here is that Ohm law expresses a difference of complex tensions in term of a complex intensity, or the intensity that is measured (here i1) is in fact the magnitude ofthe complex intensity. Therefore the Math.hypot is needed to express this magnitude.

Copy link
Member

Choose a reason for hiding this comment

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

Yes but it would be simpler to calculate re(i) and img(i) and then mod(i) that calculating p and q and then dividing by voltage for nothing

Copy link
Member

Choose a reason for hiding this comment

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

Sure it would be more efficient.

Djazouli and others added 15 commits March 5, 2021 17:55
Signed-off-by: Gael Macherel <gael.macherel@artelys.com>
Signed-off-by: Gael Macherel <gael.macherel@artelys.com>
Signed-off-by: Gael Macherel <gael.macherel@artelys.com>
Signed-off-by: Gael Macherel <gael.macherel@artelys.com>
Signed-off-by: Gael Macherel <gael.macherel@artelys.com>
Signed-off-by: Gael Macherel <gael.macherel@artelys.com>
Signed-off-by: Gael Macherel <gael.macherel@artelys.com>
Signed-off-by: Gael Macherel <gael.macherel@artelys.com>
Signed-off-by: Anne Tilloy <anne.tilloy@rte-france.com>
Signed-off-by: Anne Tilloy <anne.tilloy@rte-france.com>
Signed-off-by: Gael Macherel <gael.macherel@artelys.com>
Signed-off-by: Anne Tilloy <anne.tilloy@rte-france.com>
Signed-off-by: Gael Macherel <gael.macherel@artelys.com>
@@ -19,6 +19,8 @@
*/
abstract class AbstractBranchAcFlowEquationTerm extends AbstractNamedEquationTerm {

public static final double NORMALIZATION_FACTOR = 1000d / Math.sqrt(3d);
Copy link
Member

Choose a reason for hiding this comment

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

Maybe you could add a reference to CURRENT in the name.

}
}

private List<SensitivityValue> getPostContingencySensitivityValues(List<LfSensitivityFactor<ClosedBranchSide1ActiveFlowEquationTerm>> lfFactors,
protected void setReferenceActivePowerFlows(List<LfSensitivityFactor<? extends AbstractClosedBranchAcFlowEquationTerm>> factors) {
Copy link
Member

Choose a reason for hiding this comment

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

You have to change the method name, and go back to one of your first choices setReferenceFunctions maybe?

Copy link
Member

@annetill annetill left a comment

Choose a reason for hiding this comment

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

Some small changes but okay!

Djazouli and others added 3 commits March 11, 2021 13:31
Signed-off-by: Gael Macherel <gael.macherel@artelys.com>
Signed-off-by: Anne Tilloy <anne.tilloy@rte-france.com>
Signed-off-by: Gael Macherel <gael.macherel@artelys.com>
@annetill annetill changed the title add intensity sensitivity Add sensitivit Mar 15, 2021
@annetill annetill changed the title Add sensitivit Add sensitivities on intensity Mar 15, 2021
@annetill
Copy link
Member

It seems that we have performance issues with that PR. Can we add a parameter to compute intensity only for sensitivity analysis involving factors that need too ? For load flow computation, we will have to compute intensity only after a NR convergence.

Signed-off-by: Gael Macherel <gael.macherel@artelys.com>
Signed-off-by: Gael Macherel <gael.macherel@artelys.com>
/**
* @author Gael Macherel <gael.macherel at artelys.com>
*/
public class AllBranchesManager implements CurrentBranchesManager {
Copy link
Member

Choose a reason for hiding this comment

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

Maybe AllCurrentBranchesManager?

/**
* @author Gael Macherel <gael.macherel at artelys.com>
*/
public class SpecificBranchesManager implements CurrentBranchesManager {
Copy link
Member

Choose a reason for hiding this comment

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

Maybe SpecificCurrentBranchesManager?

Signed-off-by: Gael Macherel <gael.macherel@artelys.com>
@@ -17,14 +20,21 @@

private final boolean forceA1Var;

private final BranchesCurrentManager branchesCurrentManager;
Copy link
Member

Choose a reason for hiding this comment

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

BranchesCurrentManager is probably too much for just a branch list filtering, why not just a list of branch id and empty (or null) means all branches?

@@ -66,7 +66,8 @@ private void reIndex() {

Set<Variable> variablesToFind = new HashSet<>();
for (Equation equation : equations.values()) {
if (equation.isActive()) {
if (equation.isActive() && EquationUpdateType.DEFAULT.equals(equation.getUpdateType())) {
Copy link
Member

Choose a reason for hiding this comment

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

It is safe to compare enum with == in Java

for (Equation equation : equations.values()) {
equation.update(x);
if (updateType.equals(equation.getUpdateType())) {
Copy link
Member

Choose a reason for hiding this comment

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

Same

Signed-off-by: Gael Macherel <gael.macherel@artelys.com>
@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 4 Code Smells

91.2% 91.2% Coverage
0.0% 0.0% Duplication

@annetill annetill merged commit d8dad84 into master Mar 17, 2021
@annetill annetill deleted the intensity_from_ac branch March 17, 2021 10:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants