-
Notifications
You must be signed in to change notification settings - Fork 11
Equation model vectorization #1275
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
base: main
Are you sure you want to change the base?
Conversation
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]>
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]>
src/main/java/com/powsybl/openloadflow/equations/SingleEquation.java
Outdated
Show resolved
Hide resolved
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; | ||
| } |
There was a problem hiding this comment.
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> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extends SingleEquationTerm
There was a problem hiding this comment.
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; | ||
|
|
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) | |||
There was a problem hiding this comment.
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) | |||
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why was SPDX removed ?
There was a problem hiding this comment.
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/. | ||
| */ |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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]>
|



Please check if the PR fulfills these requirements
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
Equationobjects) with its specificEquationTerm. Data (V, phi, Pi model characteristics...) is stored directly in theEquationTermobjects and the term is evaluated througheval()andder()implementations.Figure 1 : Simplified view of an equation system implemented with the old behaviour

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
EquationArrayobject that contains one uniqueEquationTermArrayfor each type of terms. Data (V, phi, Pi model characteristics...) is stored in anAcNetworkVectorobject, and all terms are evaluated once with theeval()andder()methods of theEquationTermArray.Previous single equations still remain for other types (
Equationare renamedSingleEquationandEquationTermare renamedSingleEquationTerm).EquationArraycan also include specifSingleEquationTermobjects 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

Does this PR introduce a breaking change or deprecate an API?
If yes, please check if the following requirements are fulfilled
What changes might users need to make in their application due to this PR? (migration steps)
Other information: