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

Feature apply action #4

Merged
merged 124 commits into from
Nov 2, 2023
Merged

Feature apply action #4

merged 124 commits into from
Nov 2, 2023

Conversation

yojvr
Copy link
Member

@yojvr yojvr commented Aug 18, 2023

[BREAKING] First Pull request into master branch. This request contains the first version of the PypowsyblBackend class and has been launched with error-fee executions on the cases 14 and 1888 from RTE.

[NEW] First implementation of the PypowsyblBackend class with its main methods : apply_action, load_grid, runpf and get_topo_vect.
[NEW] Some unit tests in the Python script test_PowsyblBackend.py.

[TODO] Investigate slack bus' and shunts' behaviour, manage storages and fix bug caused by the move_connectable function from the pypowsybl interface on the generators elements.
[TODO] Increase the rate of OK unit tests

@tschuppr tschuppr force-pushed the feature_apply_action branch 2 times, most recently from 08deb55 to 5a0da81 Compare August 28, 2023 16:40
@tschuppr tschuppr linked an issue Aug 28, 2023 that may be closed by this pull request
@marota
Copy link

marota commented Sep 6, 2023

As mentioned in our meeting end of August, could you guide the furture PR reviewer to things that are most important to look at ?
75 files to look at at once and 89 commits is not something bearable as is for a review.

Looking forward for your help in making this smoother, thanks

@vinault vinault assigned vinault and unassigned vinault Sep 18, 2023
@tschuppr
Copy link
Member

Implementation of backend for Grid2op

There is two important files that are really implementing the powsyblBackend in the manner of pandapower backend is implemented in Grid2op. Most of the functions' name are identical, some little bit of architectures might change because of the specificity of Powsybl but they are for most explained in the Readme.

One of those file is an help to better load network called Network and is helping to keep DataFrames order when loading loads.

The other is our main contribution PowsyblBackend and implements all the needed functions for a backend to work properly with Grid2op and most of optionnal ones except the mananagment of storages and slack buses.

Implementation of tests for the integration

The file to launch test on pytest following integration of pandapower test on Grid2op : general_tests

And the related file, very similar to the one in Grid2op, with changes on some values to adapt to powsybl results : BaseBackendTestPyPowsybl

Part on chronics creation

We also add a part to create suitable chronics to test our backend on bigger networks because original chronics were having some naming issues that are due to matpower translations.
The file : ChronicsCreator

@marota
Copy link

marota commented Sep 26, 2023

Pour cette PR, une evol de pypowsybl a été nécessaire tel que référencée ici: powsybl/pypowsybl#654

Copy link

@BDonnot BDonnot left a comment

Choose a reason for hiding this comment

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

Main thing: some tests of grid2op need to be done to make sure the backend is working

ChronicsCreator.py Outdated Show resolved Hide resolved
ChronicsCreator.py Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
poetry.lock Outdated Show resolved Hide resolved
src/tests/test_PowsyblBackend.py Outdated Show resolved Hide resolved
README.md Show resolved Hide resolved
@tschuppr
Copy link
Member

tschuppr commented Oct 18, 2023

Content of this PR

Important information

You should read the README.md file to install the environment the right way if you want to test how our implementation is working, a script of simple example is available there.

Main file : powsybl_backend.py

We developed all the principal methods that are mandatory for a backend to work with grid2op:

  • load_grid() : Load the grid from a data file (.json, .mat or .xiidm) and initialize all the correspondant objects in Grid2op with their relative values.
  • apply_action() : Apply a desired action designed in grid2op to the pypowsybl network by updating all the electrical objects.
  • runpf() : Launch a loadflow using pypowsybl (either in AC/DC depending on the input parameter) thanks to pypowsybl loadflow and then update the values of the different parameters of the grid2op grid with the results of the computation.
  • get_topo_vect() : Get the topology vector which shows to which bus each component is connected if it is or not connected at all otherwise.
  • generators_info() : Return the information of active/reactive power production of each generator and the voltage level on the bus they are connected to.
  • loads_info() : Return the information of active/reactive power consumption of each load and the voltage level on the bus they are connected to.
  • lines_or_info() : Return the information of active/reactive power flowing in each line, the voltage level on the bus they are connected to and their actual current. This is done here at the origin bus of the lines.
  • lines_ex_info() : Return the information of active/reactive power flowing in each line, the voltage level on the bus they are connected to and their actual current. This is done here at the extremity bus of the lines.

We also developed some of the optional methods:

  • copy() : There is not really a lot of reflection for this method we just hard copied all the elements of the Grid2op network and the initial pypowsybl grid after loading the grid from a file
  • get_line_status : This methods give the information of connection/disconnection of every line/transfo in the grid.

We designed methods for the ease of use of our backend:

  • Methods starting by _apply_ and their sub functions starting with _change_bus have been developed to make more understandable the apply_action() function and are all used to switch the bus of an element.
  • Methods starting by _aux_ are auxiliary functions to get an electrical element some properties from the pypowsybl representation of the grid.
  • Method _double_buses have been designed to double the bus of the initial grid we load in the pypowsybl representation. The idea is to have a configuration with whom we will not be forced to make some choices from a topological point of view, i.e. not having to choose where to connect the electrical object when we want to change its bus.
  • _init_private_attrs() : This method is used to clarify the loading of all the parameters.

Test suite

The tests have been mostly inspired by those of Grid2op. Nevertheless they have been adapted to the particularities of our backend and we reduced their number to focus on the most important.

Some data have also been adapted to help the testing see data_test. Those data are using ieee14rte grid and the chronics have been adapted from Grid2op package test case to work with pypowsybl. We also took a file created to generate working chronics from a @BDonnot repo and adapted it for pypowsybl to create synthetic but realist chronics for bigger nets that were not having any chronic available.

All the tests are not passing but most of them are. Some more understanding should be done on the reasons (see TODO).

Future improvements

PR2

The issue concerning this PR is there PR2

  • Packaging on Pypi.
  • Updating chronics_creator to be able to create working datasets for our backend.
  • Having a working Ci/CD

PR3

This PR will be more specific to the needs of the AIRGo project, more information are available here PR3

TODO

  • Resolve the issues that stay in the repo
  • Finish to integrate storage and other objects that are supported both by grid2op and pypowsybl that are not currently implemented
  • Improving the tests and add some to the existing ones

@annetill annetill merged commit 8a59569 into main Nov 2, 2023
2 checks passed
flo-dup added a commit that referenced this pull request Nov 2, 2023
Signed-off-by: Yoann Janvier <[email protected]>
Signed-off-by: rtschupp <[email protected]>
Signed-off-by: Vincent Renault <[email protected]>
flo-dup added a commit that referenced this pull request Nov 2, 2023
Signed-off-by: Yoann Janvier <[email protected]>

Signed-off-by: rtschupp <[email protected]>

Signed-off-by: Vincent Renault <[email protected]>
flo-dup added a commit that referenced this pull request Nov 2, 2023
Signed-off-by: Yoann Janvier <[email protected]>
Co-authored-by: rtschupp <[email protected]>
Co-authored-by: Vincent Renault <[email protected]>
flo-dup pushed a commit that referenced this pull request Nov 2, 2023
Signed-off-by: Yoann Janvier <[email protected]>
Co-authored-by: rtschupp <[email protected]>
Co-authored-by: Vincent Renault <[email protected]>
flo-dup pushed a commit that referenced this pull request Nov 2, 2023
Signed-off-by: Yoann Janvier <[email protected]>
Co-authored-by: rtschupp <[email protected]>
Co-authored-by: Vincent Renault <[email protected]>
flo-dup pushed a commit that referenced this pull request Nov 2, 2023
Signed-off-by: Yoann Janvier <[email protected]>
Co-authored-by: rtschupp <[email protected]>
Co-authored-by: Vincent Renault <[email protected]>
flo-dup pushed a commit that referenced this pull request Nov 2, 2023
Signed-off-by: Yoann Janvier <[email protected]>
Co-authored-by: rtschupp <[email protected]>
Co-authored-by: Vincent Renault <[email protected]>
flo-dup pushed a commit that referenced this pull request Nov 2, 2023
Signed-off-by: Yoann Janvier <[email protected]>
Co-authored-by: rtschupp <[email protected]>
Co-authored-by: Vincent Renault <[email protected]>
@flo-dup flo-dup deleted the feature_apply_action branch November 2, 2023 14:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

MATPOWER French Network
8 participants