Skip to content

[CGMES] Less internal connections created at import #3210

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

Open
wants to merge 24 commits into
base: main
Choose a base branch
from

Conversation

flo-dup
Copy link
Collaborator

@flo-dup flo-dup commented Nov 13, 2024

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)

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 connectable and switch is created with two nodes at each end, one for the cim:ConnectivityNode, one for the cim:Terminal. The two nodes are connected with an InternalConnection. This leads to a verbose iidm file with an excessive number of InternalConnections.

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

When the configuration is the following:

  • iidm.import.cgmes.create-fictitious-switches-for-disconnected-terminals-mode is NEVER (default value is ALWAYS)
  • and iidm.import.cgmes.create-busbar-section-for-every-connectivity-node is false (which is the default value)

The InternalConnection is created only if needed:

  • if there's only one Connectable at the ConnectivityNode, no InternalConnection
  • if there are two Connectables at the ConnectivityNode, only one InternalConnection is created, for the first Connectable encountered (instead of one for each)
  • if there are more than two Connectables, one InternalConnection is created between each terminal and the ConnectivityNode, except for the BusbarSection case:
    • if there's exactly one BusbarSection among the connectables, the InternalConnection are created between this BusbarSection and the other connectables
    • if there's more than one BusbarSection (does not make so much sense, but exists in real data), the InternalConnections are created between the first BusbarSection and all the other Connectables, including the other BusbarSections.

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

  • Yes
  • No

@flo-dup flo-dup requested a review from rcourtier November 13, 2024 14:43
@zamarrenolm
Copy link
Member

Just one quick consideration: could all these rules/simplification of the underlying connectivity model be moved to a post-processor after import (or a network modification). This way it could be useful for all importers, in a centralised way, and we should not need to consider them in every importer that have to handle. For example, recent versions of PSSE (35 and later) support node/breaker models where we could face similar problems.

@flo-dup flo-dup marked this pull request as ready for review February 19, 2025 15:37
@flo-dup flo-dup requested a review from olperr1 February 19, 2025 15:39
The node mapping is done at once for all terminals connected to a given connectivity node

Signed-off-by: Florian Dupuy <[email protected]>
@flo-dup
Copy link
Collaborator Author

flo-dup commented Feb 21, 2025

Just one quick consideration: could all these rules/simplification of the underlying connectivity model be moved to a post-processor after import (or a network modification). This way it could be useful for all importers, in a centralised way, and we should not need to consider them in every importer that have to handle. For example, recent versions of PSSE (35 and later) support node/breaker models where we could face similar problems.

Thanks for pointing out that similarity with PSSE! But we should rather centralize it in a utility method. Post-processing is not the good way to go I think (in terms of performance, robustness, and readability). That's at the cost of handling the utility method call (and map building beforehand) in each importer, and having an abstraction which allows it, sure. If that's not possible, I think we should rather duplicate the logic than putting it in a common postprocessing.

@flo-dup
Copy link
Collaborator Author

flo-dup commented Feb 27, 2025

Tested on ENTSO-E CGMES sample data SmallGrid/NodeBreaker

Without this PR With this PR
iidm export file size 630ko 450ko
internal connections 2834 136
read time on my laptop (averaged over 100 iterations) 0.81094s 0.80416s

Signed-off-by: Florian Dupuy <[email protected]>
flo-dup added 4 commits March 3, 2025 10:03
Signed-off-by: Florian Dupuy <[email protected]>
Signed-off-by: Florian Dupuy <[email protected]>
Signed-off-by: Florian Dupuy <[email protected]>
olperr1
olperr1 previously approved these changes Mar 3, 2025
@flo-dup flo-dup requested a review from rcourtier March 3, 2025 15:43
@Test
void testNever() {
Properties cgmesImportParameters = new Properties();
cgmesImportParameters.put(CgmesImport.CREATE_FICTITIOUS_SWITCHES_FOR_DISCONNECTED_TERMINALS_MODE, "NEVER");
Copy link
Member

Choose a reason for hiding this comment

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

Functionnally, this parameter shouldn't change the result.
Since you didn't provide a SSH file, all terminals are considered connected.

if (!connected && createFictitiousSwitch(fictSwCreationMode, isSwitchEnd)) {
createFictitiousSwitch(t, vl);
} else {
createInternalConnection(t, vl);
Copy link
Member

Choose a reason for hiding this comment

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

You don't have to systematically create a node for the terminal and an internal connection between the terminal's node and the connectivitynode's node. You could do it only if needed, that is if 2 or more connected non-switch equipments share that terminal's connectivity node.

Comment on lines 34 to 38
Network network = Network.read("multiTerminalConnectivityNodes.xml",
getClass().getResourceAsStream("/multiTerminalConnectivityNodes.xml"),
LocalComputationManager.getDefault(),
ImportConfig.load(),
cgmesImportParameters);
Copy link
Member

Choose a reason for hiding this comment

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

To simplify the import, you may use a method from ConversionUtil class in com.powsybl.cgmes.conversion.test package:

public static Network readCgmesResources(Properties properties, String dir, String... files)

That may be especially handy when you need to read several files (like EQ and SSH instance).

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.

5 participants