Single Line Diagram - SVG Writing#

Amsterdam_substation

We are showing in this guide how to create some single line diagrams, like the one above. We first generate such a diagram from a test network, then from a CGMES file. To that end, we use the com.powsybl.sld.SingleLineDiagram class, which is the central API of powsybl-single-line-diagram.

Prerequisites#

Maven dependencies#

First of all, we need some Maven dependencies.

  • If you want to get a quick start, please add the powsybl-starter dependency to your pom file:

<dependency>
    <groupId>com.powsybl</groupId>
    <artifactId>powsybl-starter</artifactId>
    <version>2025.2.0</version>
</dependency>
  • If you only want to import the strictly needed dependencies for this tutorial, you can write a more detailed pom file:

Roll/unroll dependencies

{% highlight xml %}

com.powsybl powsybl-dependencies ${powsybl-dependencies.version} pom import com.powsybl powsybl-single-line-diagram-core com.powsybl powsybl-iidm-impl com.powsybl powsybl-iidm-test com.powsybl powsybl-cgmes-conversion com.powsybl powsybl-triple-store-impl-rdf4j org.slf4j slf4j-simple ${slf4j.version} 2025.2.0 1.7.22

{% endhighlight %}

Here are some details about these dependencies (see also the [powsybl artifacts documentation page]()): - `powsybl-single-line-diagram-core` is the core module of single-line-diagram, - `powsybl-iidm-impl` is used to deal with the network model, - `powsybl-iidm-test` is used to load the test network, - `powsybl-cgmes-conversion` and `powsybl-triple-store-impl-rdf4j` are used to import a CGMES file, - `slf4j-simple` allows you to have simple logging capabilities.

Diagrams from a test network#

We first create the node/breaker test Network we are interested in:

Network network = FictitiousSwitchFactory.create();

Generating a voltage level diagram#

We can generate the SVG diagram file for voltage level N with a single line of code:

SingleLineDiagram.draw(network, "N", "/tmp/n.svg");

Note that we could also use a method specific for voltage levels:

SingleLineDiagram.drawVoltageLevel(network, "N", "/tmp/n.svg");

We obtain the following SVG:

N_voltageLevel

Similarly, we could generate a SVG for voltage level C:

SingleLineDiagram.draw(network, "C", "/tmp/c.svg");

leading to the following diagram:

C_voltageLevel

Generating the substation diagram#

In order to build the diagram for the whole substation, named A, containing both voltage levels displayed previously, we may use the same interface:

SingleLineDiagram.draw(network, "A", "/tmp/a.svg");

Similarly to before, there is also a method specific for substations which we could have used:

SingleLineDiagram.drawSubstation(network, "A", "/tmp/a.svg");

In both cases, we obtain the following wider SVG file:

A_substation

Diagrams from a CGMES file#

First of all, we need to download a sample file from ENTSO-E here

This file is named CGMES_v2_4_15_MicroGridTestConfiguration_T4_Assembled_NB_Complete_v2.zip.

We first import this sample Network we are interested in:

String file = "/path/to/file/CGMES_v2_4_15_MicroGridTestConfiguration_T4_Assembled_NB_Complete_v2.zip";
Network network = Network.read(file);

Generating a voltage level diagram#

Once the network is loaded, we can generate diagrams like in previous section. We first generate a SVG for the voltage level named 110 in substation PP_Brussels (corresponding id is _8bbd7e74-ae20-4dce-8780-c20f8e18c2e0). Note that, as the ids are not very human-readable, we customize the parameters to have the names displayed instead of the ids. Therefore, we use the slightly more complex interface SingleLineDiagram.draw(network, id, path, parameters).

// Use custom parameters to have the names displayed instead of the ids
SvgParameters svgParameters = new SvgParameters().setUseName(true);
SldParameters sldParameters = new SldParameters().setSvgParameters(svgParameters);
// Draw the diagram of voltage level 110 in substation PP_Brussels (id _8bbd7e74-ae20-4dce-8780-c20f8e18c2e0)
SingleLineDiagram.draw(network, "8bbd7e74-ae20-4dce-8780-c20f8e18c2e0", Paths.get("/tmp/Brussels110.svg"), sldParameters);

We obtain the following SVG:

Brussels_voltageLevel

Generating a substation diagram#

Similarly to voltage level diagrams, we can generate substation diagrams. We generate the SVG diagram for the substation called PP_Amsterdam, which is containing four voltage levels. We customize a bit further the parameters: the feeder names in this substation are quite long, hence we rotate them to avoid overlapping.

// Customize further the parameters to have the feeders label rotated, in order to avoid overlapping
svgParameters.setLabelDiagonal(true);

// Draw the diagram of substation PP_Amsterdam (id _c49942d6-8b01-4b01-b5e8-f1180f84906c)
SingleLineDiagram.draw(network, "c49942d6-8b01-4b01-b5e8-f1180f84906c", Paths.get("/tmp/AmsterdamSubstation.svg"), sldParameters);

We then obtain the following SVG file representing the whole PP_Amsterdam substation with its three voltage levels:

Amsterdam_substation

That’s it, you are now able to generate diagrams for substations and voltage levels! You can now try to change the default layout settings by reading the next guide SVG Layouts.