Skip to content

Conversation

@geofjamg
Copy link
Member

@geofjamg geofjamg commented Sep 2, 2025

Please check if the PR fulfills these requirements

  • 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)
  • A PR or issue has been opened in all impacted repositories (if any)

Does this PR already have an issue describing the problem?

No

What kind of change does this PR introduce?

Feature

What is the current behavior ?

Each equation is stored separately (in Equation objects) with its specific EquationTerm. Data (V, phi, Pi model characteristics...) is stored directly in the EquationTermobjects and the term is evaluated through eval() and der() implementations.

Figure 1 : Simplified view of an equation system implemented with the old behaviour
Equation(old)

What is the new behavior (if this is a feature change)?

In addition to existing scalar equation model, we added an array equation model that allow a more compact model and improve evaluation of equations and its derivatives. For closed branch terms, for bus active target and bus reactive target equations, the vectorized view is implemented. All equations of the same type are stored in one unique EquationArray object that contains one unique EquationTermArray for each type of terms. Data (V, phi, Pi model characteristics...) is stored in an AcNetworkVector object, and all terms are evaluated once with the eval() and der() methods of the EquationTermArray.
Previous single equations still remain for other types (Equation are renamed SingleEquation and EquationTerm are renamed SingleEquationTerm). EquationArray can also include specif SingleEquationTerm objects for specific equations (e.g. open branch terms or AC emulation)

Figure 2 : Simplified view of the same equation system implemented with the new behaviour
Equation(new) 2

Does this PR introduce a breaking change or deprecate an API?

  • Yes
  • No

If yes, please check if the following requirements are fulfilled

  • The Breaking Change or Deprecated label has been added
  • The migration steps are described in the following section

What changes might users need to make in their application due to this PR? (migration steps)

Other information:

geofjamg and others added 30 commits July 3, 2023 21:27
Signed-off-by: Geoffroy Jamgotchian <[email protected]>
Signed-off-by: Geoffroy Jamgotchian <[email protected]>
Signed-off-by: Geoffroy Jamgotchian <[email protected]>
Signed-off-by: Geoffroy Jamgotchian <[email protected]>
# Conflicts:
#	src/main/java/com/powsybl/openloadflow/ac/equations/AcEquationSystemCreator.java
Signed-off-by: Geoffroy Jamgotchian <[email protected]>
# Conflicts:
#	src/main/java/com/powsybl/openloadflow/network/LfNetwork.java
Signed-off-by: Geoffroy Jamgotchian <[email protected]>
Signed-off-by: Geoffroy Jamgotchian <[email protected]>
Signed-off-by: Geoffroy Jamgotchian <[email protected]>
Signed-off-by: Geoffroy Jamgotchian <[email protected]>
Signed-off-by: Geoffroy Jamgotchian <[email protected]>
Signed-off-by: Geoffroy Jamgotchian <[email protected]>
Signed-off-by: Geoffroy Jamgotchian <[email protected]>
Signed-off-by: Geoffroy Jamgotchian <[email protected]>
Signed-off-by: Geoffroy Jamgotchian <[email protected]>
# Conflicts:
#	src/main/java/com/powsybl/openloadflow/ac/equations/AcEquationSystemCreator.java
#	src/main/java/com/powsybl/openloadflow/ac/equations/asym/AsymmetricalAcEquationSystemCreator.java
Signed-off-by: Geoffroy Jamgotchian <[email protected]>
Signed-off-by: Geoffroy Jamgotchian <[email protected]>
Signed-off-by: Geoffroy Jamgotchian <[email protected]>
Signed-off-by: Geoffroy Jamgotchian <[email protected]>
# Conflicts:
#	src/main/java/com/powsybl/openloadflow/ac/equations/AcEquationSystemCreator.java
Signed-off-by: Geoffroy Jamgotchian <[email protected]>
SylvestreSakti and others added 12 commits November 25, 2025 17:37
Signed-off-by: Geoffroy Jamgotchian <[email protected]>
Signed-off-by: Geoffroy Jamgotchian <[email protected]>
Signed-off-by: Geoffroy Jamgotchian <[email protected]>
Signed-off-by: Geoffroy Jamgotchian <[email protected]>
# Conflicts:
#	src/main/java/com/powsybl/openloadflow/ac/AcLoadFlowParameters.java
#	src/test/java/com/powsybl/openloadflow/OpenLoadFlowProviderTest.java
Signed-off-by: Geoffroy Jamgotchian <[email protected]>
Signed-off-by: Geoffroy Jamgotchian <[email protected]>
Signed-off-by: Geoffroy Jamgotchian <[email protected]>
Signed-off-by: Geoffroy Jamgotchian <[email protected]>
Signed-off-by: Geoffroy Jamgotchian <[email protected]>
Signed-off-by: Geoffroy Jamgotchian <[email protected]>
Signed-off-by: Geoffroy Jamgotchian <[email protected]>
Signed-off-by: Geoffroy Jamgotchian <[email protected]>
singleTermsByEquationElementNum.computeIfAbsent(elementNum, k -> new AdditionalSingleTermsByEquation())
.addSingleTerm(singleEquationTerm, this);
hasSingleEquationTerms[elementNum] = true;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

else throw something ? (to avoid silent errors)

/**
* @author Sylvestre Prabakaran {@literal <sylvestre.prabakaran at rte-france.com>}
*/
public interface ClosedBranchAcFlowEquationTerm extends EquationTerm<AcVariableType, AcEquationType> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

extends SingleEquationTerm

Copy link
Member

Choose a reason for hiding this comment

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

Is this compulsory ? We could imagine an EquationTermArrayElement (that is not a SingleEquationTerm) that implements this interface

protected final Variable<AcVariableType> v2Var;
protected final Variable<AcVariableType> a1Var;
protected final Variable<AcVariableType> r1Var;

Copy link
Collaborator

Choose a reason for hiding this comment

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

For transformers with tap changers this may become wrong if the tap changes (especially for r1 and a1).
This object works only if its lifecycle is short and it is not used longer than an ACSolver solve.

Copy link
Member

Choose a reason for hiding this comment

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

This is the case since this term is built only during one step of derivative calculation. Comment added to clarify that.

Stopwatch stopwatch = Stopwatch.createStarted();

var equations = equationSystem.getIndex().getSortedEquationsToSolve();
var equations = equationSystem.getIndex().getSortedSingleEquationsToSolve();
Copy link
Collaborator

Choose a reason for hiding this comment

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

This variable is no longer needed .

equationSystem.getIndex().getSortedEquationsToSolve() can be in the loop (after ). Would make the code cleaner and more symetric.:

array[equation.getColumn()] = equation.evalLhs();
}
for (EquationArray<V, E> equationArray : equationSystem.getEquationArrays()) {
equationArray.eval(array);
Copy link
Collaborator

@vidaldid-rte vidaldid-rte Nov 28, 2025

Choose a reason for hiding this comment

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

maybe a simple fix to split in two iterations as discussed
One on the array terms
One on the single terms of equations array that add (their sum) to the array cell (in a way that minimizes the number of small objetc to load - ideally only the active single terms)
So that the flow on array terms remains linear and fast.

Copy link
Member

Choose a reason for hiding this comment

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

To be studied when improving this PR for the next release, but as discussed, it may not be needed since there are only 4 equation arrays.

@@ -0,0 +1,326 @@
/**
* Copyright (c) 2023, RTE (http://www.rte-france.com)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is 2023 really the latest modification date for this class ? shouldn't if be 2023-2025

@@ -1,9 +1,8 @@
/**
* Copyright (c) 2019, RTE (http://www.rte-france.com)
* Copyright (c) 2025, RTE (http://www.rte-france.com)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Coyright is usually creationYear-lastModificatinYear. Should be 2019-2025

* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
* SPDX-License-Identifier: MPL-2.0
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why was SPDX removed ?

Copy link
Member

Choose a reason for hiding this comment

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

SPDX added

* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
Copy link
Collaborator

Choose a reason for hiding this comment

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

No SPDX ?
Has the rule changed since this 2024 campaign ? #1019

Copy link
Member

Choose a reason for hiding this comment

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

SPDX added

Signed-off-by: PRABAKARAN Sylvestre <[email protected]>
Signed-off-by: PRABAKARAN Sylvestre <[email protected]>
@sonarqubecloud
Copy link

sonarqubecloud bot commented Dec 1, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants