geofjamg / pypowsybl

PowSyBl for Python
Mozilla Public License 2.0
0 stars 0 forks source link

PyPowSyBl

MPL-2.0 License Join the community on Spectrum

The PyPowSyBl project gives access to PowSyBl Java framework to Python developers. This Python integration relies on JPype. This is not a native implementation of PowSyBl features: internally a JVM is started to run the java code, and the Python code access to the Java objects through JNI.

Table of contents

Requirements

This project contains both Java and Python source files. To build the project, you need to install:

Ubuntu

$> sudo apt install python3 python3-jpype python3-pip python3-wheel

CentOS

$> sudo yum install python3 python3-jpype python3-pip python3-wheel

Install

To install PyPowSyBl, you can either use the binary package or build the project from the sources.

Install from the binaries

Download the latest version of the PyPowSyBl and install the package with pip:

$> pip3 install pypowsybl-1.0.0-py3-none-any.whl

This command requires privileges but you can also install the package for the current user only:

$> pip3 install --user pypowsybl-1.0.0-py3-none-any.whl

This will require to update your PYTHONPATH environment variable to make the package accessible in your scripts:

export PYTHONPATH=$PYTHONPATH:$HOME/.local/lib/python3.8/site-packages

Install from the sources

To build and install PyPowSyBl from the sources, you need to clone this repository using git.

$> git clone https://github.com/powsybl/pypowsybl

All the build is managed by Maven. It will compile the Java classes and package them in powsybl-pypowsybl-<VERSION>.jar file, download all the Java dependencies declared in the pom.xml file and create an python wheel package.

$> mvn package

Once it's done, you simply have to install the package:

$> pip3 install target/dist/pypowsybl-1.0.0-py3-none-any.whl

Note: in case of any change from the binaries or from the sources (either from Java code or from Python code), you have to reinstall the package either by uninstalling and reinstalling the package or by passing the -I option to pip3:

$> pip3 install -I target/dist/pypowsybl-1.0.0-py3-none-any.whl

Demo

A small demo is provided in the demo folder. It shows how to load a case-file, run a load-flow and export the updated network to another case file to the temporary directory.

$> python3 demo.py

Contributing

If you are interested in the PyPowSyBl project, feel free to contribute. All the information you need are available on our website.