Skip to content

Persistent implementation of PowSyBl network based on Spring Boot

License

Notifications You must be signed in to change notification settings

powsybl/powsybl-network-store

PowSyBl Network Store Client

Actions Status Coverage Status MPL-2.0 License Join the community on Spectrum Slack

PowSyBl (Power System Blocks) is an open source framework written in Java, that makes it easy to write complex software for power systems’ simulations and analysis. Its modular approach allows developers to extend or customize its features.

PowSyBl is part of the LF Energy Foundation, a project of The Linux Foundation that supports open source innovation projects within the energy and electricity sectors.

PowSyBl Logo

Read more at https://www.powsybl.org !

This project and everyone participating in it is governed by the PowSyBl Code of Conduct. By participating, you are expected to uphold this code. Please report unacceptable behavior to [email protected].

PowSyBl vs PowSyBl Network Store Client

Getting started

Build

cd powsybl-network-store
mvn clean install

Import a network in the database

In your preferred IDE, create a project with following dependencies:

<dependency>
    <groupId>com.powsybl</groupId>
    <artifactId>powsybl-network-store-client</artifactId>
    <version>1.7.0</version>
</dependency>
<dependency>
    <groupId>com.powsybl</groupId>
    <artifactId>powsybl-iidm-test</artifactId>
    <version>6.0.2</version>
</dependency>

Run the Java code to import in IIDM store a programmatic test node/breaker network:

public static void main(String[] args) throws Exception {
    String baseUrl = "http://localhost:8080/";
    try (NetworkStoreService service = new NetworkStoreService(baseUrl, PreloadingStrategy.NONE)) {
    	Network network = NetworkTest1Factory.create(service.getNetworkFactory());
    }
}

Import a network from a file in the database

public static void main(String[] args) throws Exception {
    String baseUrl = "http://localhost:8080/";
    try (NetworkStoreService service = new NetworkStoreService(baseUrl, PreloadingStrategy.NONE)) {
        Network network = service.importNetwork(Paths.get("/tmp/network1.xiidm"));
    }
}

List voltage levels from a stored network

public static void main(String[] args) throws Exception {
    String baseUrl = "http://localhost:8080/";
    try (NetworkStoreService service = new NetworkStoreService(baseUrl, PreloadingStrategy.COLLECTION)) {
        Network network = service.getNetwork("network1");
        for (VoltageLevel vl : network.getVoltageLevels()) {
            System.out.println(vl.getId());
        }
   }
}

Injection network store service in a Spring controller

@RestController
@RequestMapping(value = "/test")
@ComponentScan(basePackageClasses = {NetworkStoreService.class})
public class TestController {

    @Autowired
    private NetworkStoreService service;

    @RequestMapping(method = GET, produces = APPLICATION_JSON_VALUE)
    public List<String> getSubstations(String networkId) {
        Network network = service.getNetwork(networkId, PreloadingStrategy.COLLECTION);
        return network.getSubstationStream().map(Identifiable::getId).collect(Collectors.toList());
    }
}

Network store service could be configured using application.yml like this:

powsybl:
    services:
        network-store-server:
            base-uri: http://localhost:8080/
            preloading-strategy: COLLECTION

List of available variables:

Variable Description Optional Default vallue
powsybl.services.network-store-server.base-uri URL of the network store server Yes http://network-store-server/
powsybl.services.network-store-server.preloading-strategy Preloading strategy Yes NONE

Run integration tests

You can run the integration tests:

$ mvn verify