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

CGMES export: Add a parameter to export as bus branch #3315

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

Conversation

rcourtier
Copy link
Member

@rcourtier rcourtier commented Feb 7, 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)

Does this PR already have an issue describing the problem?

No.

What kind of change does this PR introduce?

New feature.

Does this PR introduce a new Powsybl Action implying to be implemented in simulators or pypowsybl?

  • Yes, the corresponding issue is here
  • No

What is the current behavior?

CGMES export's topology kind depends on the network's topology kind computation. A network with at least one node/breaker voltage level will be exported as NODE_BREAKER, and a full bus/breaker network will always be exported as BUS_BRANCH.

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

The network topology kind computation has been revised. The network has to be a full node/breaker to be exported in CGMES as NODE_BREAKER, likewise it has to be a full bus/breaker to be exported in CGMES as BUS_BRANCH. In case of a hybrid (mixed topology) network, the computed topology kind depends on the CIM version for export: it is BUS_BRANCH in case of a CIM 16 export and NODE_BREAKER for a CIM 100 export.

A new parameter has been added to override the computed export topology kind and force a desired one. It allows for example to export a node/breaker network as BUS_BRANCH. The allowed values for this parameter are NODE_BREAKER and BUS_BRANCH.

The differences in the various configurations of CIM version and topology kind are:

  • In case of a CIM 16 BUS_BRANCH export:

    • ConnectivityNode are not exported
    • non-retained Switch are not exported
  • In case of a CIM 100 BUS_BRANCH export,

    • ConnectivityNode are exported from buses of the BusBreakerView
    • non-retained Switch are not exported
  • In case of a NODE_BREAKER export:

    • ConnectivityNode are always exported, either from nodes if the VoltageLevel is at node/breaker connectivity level, or from buses if the VoltageLevel is at bus/breaker connectivity level.
    • non-retained Switch are always exported.

Also, there is a specificity for the CIM 16 BUS_BRANCH export where this export intrinsically means not writting the equipment operation profile. This means the following classes won't be written:

  • ConnectivityNode
  • StationSupply
  • GroundDisconnector
  • ActivePowerLimit
  • ApparentPowerLimit
  • LoadArea
  • SubLoadArea
  • SvStatus

As well as the following attributes:

  • LoadGroup.LoadArea
  • LoadGroup.SubLoadArea
  • ControlArea.EnergyArea

Note: the CGMES EquipmentOperation profile contains more elements, but they don't exist in PowSyBl and are already not exported.

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)

In case of a network with mixed topology, that is with some VoltageLevel in node/breaker topology kind and some other VoltageLevel in bus/breaker topology kind, the CGMES export without this feature was always a NODE_BREAKER one. The change introduced here is that the export will now be a BUS_BRANCH one if the CIM version for export is 16 (default value).
In order to restore a NODE_BREAKER export for a mixed-topology network, one has to set the TOPOLOGY_KIND CgmesExport parameter as follows:

Network network = ...;

// Export to CGMES as node-breaker
Properties exportParameters = new Properties();
exportParameters.put(CgmesExport.TOPOLOGY_KIND, "NODE_BREAKER");
network.write("CGMES", exportParameters, Path.of("cgmes_file")); 

Other information:

@rcourtier rcourtier self-assigned this Feb 7, 2025
@rcourtier rcourtier changed the title CGMES export: Add a parameter to export a network as bus branch CGMES export: Add a parameter to export as bus branch Feb 7, 2025
@rcourtier rcourtier force-pushed the refactor_cgmesnamespace_interface branch from 30aef81 to 1e8fdfd Compare February 18, 2025 15:05
@rcourtier rcourtier force-pushed the bus_branch_export branch 6 times, most recently from 534fe97 to bec824f Compare February 20, 2025 10:01
@rcourtier rcourtier added the Breaking Change API is broken label Feb 20, 2025
@rcourtier rcourtier force-pushed the refactor_cgmesnamespace_interface branch from 1e8fdfd to 09cc8ac Compare February 25, 2025 13:30
@rcourtier rcourtier force-pushed the bus_branch_export branch 4 times, most recently from 30b97d9 to cba96a8 Compare February 26, 2025 10:37
@rcourtier rcourtier mentioned this pull request Mar 5, 2025
9 tasks
@rcourtier rcourtier force-pushed the refactor_cgmesnamespace_interface branch from c72e70d to 55af22e Compare March 5, 2025 09:37
@rcourtier rcourtier force-pushed the bus_branch_export branch from cba96a8 to 321044c Compare March 5, 2025 10:03
Base automatically changed from refactor_cgmesnamespace_interface to main March 5, 2025 13:26
Signed-off-by: Romain Courtier <[email protected]>
Signed-off-by: Romain Courtier <[email protected]>
@rcourtier rcourtier force-pushed the bus_branch_export branch from 321044c to cca2fbd Compare March 5, 2025 14:07
private static final Parameter TOPOLOGY_KIND_PARAMETER = new Parameter(
TOPOLOGY_KIND,
ParameterType.STRING,
"The topology kind of the export",
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"The topology kind of the export",
"Force the topology kind for the export (disable automatic detection)",

@@ -159,12 +159,25 @@ public ReferenceDataProvider getReferenceDataProvider() {
}

private CgmesTopologyKind networkTopologyKind(Network network) {
Copy link
Member

Choose a reason for hiding this comment

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

Can you rename this method to detectNetworkTopologyKind?
It doesn't consider the parameters, but only the network, so it should not be used to get the topology kind. With this name, it's maybe clearer.

@@ -130,4 +130,11 @@ public static String getElement(String xmlFile, String className, String rdfId)
Pattern pattern = Pattern.compile(regex, Pattern.DOTALL);
return getFirstMatch(xmlFile, pattern);
}

public static long getElementCount(String xmlFile, String className) {
String regex = "(<cim:" + className + " (rdf:ID=\"_|rdf:about=\"#_).*?\")>";
Copy link
Member

Choose a reason for hiding this comment

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

.*? can be replaced by .+.

| 100 | `BUS_BRANCH` | Yes (**) | Yes |

### Connectivity elements
* non-retained `Switch` are always written in the case of a `NODE_BREAKER` export, and never written in the case of a `BUS_BRANCH` export
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* non-retained `Switch` are always written in the case of a `NODE_BREAKER` export, and never written in the case of a `BUS_BRANCH` export
* Non-retained `Switch` are always written in the case of a `NODE_BREAKER` export, and never written in the case of a `BUS_BRANCH` export

* If some `VoltageLevel` of the network are at `node/breaker` and some other at `bus/breaker` connectivity level, then the export's topology kind depends on the CIM version for export:
it is `BUS_BRANCH` for CIM 16 and `NODE_BREAKER` for CIM 100

It is however possible to ignore the computed export topology kind and force it to be `NODE_BREAKER` or `BUS_BRANCH` by setting the parameter `iidm.export.cgmes.topology-kind`.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
It is however possible to ignore the computed export topology kind and force it to be `NODE_BREAKER` or `BUS_BRANCH` by setting the parameter `iidm.export.cgmes.topology-kind`.
It is however possible to ignore the computed export topology kind and force it to be `NODE_BREAKER` or `BUS_BRANCH` by setting the parameter [`iidm.export.cgmes.topology-kind`](#options).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Waiting for review
Development

Successfully merging this pull request may close these issues.

2 participants