Skip to main content

Expert system recommender for power grid contingency analysis based on ExpertOp4Grid principles.

Project description

ExpertOp4Grid Recommender

License: MPL 2.0 Python Version

Expert system recommender for power grid contingency analysis based on ExpertOp4Grid principles. This tool analyzes N-1 contingencies in Grid2Op/pypowsybl environments, builds overflow graphs, applies expert rules to filter potential actions, and identifies relevant corrective measures to alleviate line overloads.


Features

  • Contingency Simulation: Simulates N-1 contingencies in a Grid2Op environment.
  • Overflow Graph Generation: Builds and visualizes overflow graphs using alphaDeesp and networkx.
  • Expert Rule Engine: Filters potential grid actions (line switching, topology changes) based on predefined rules derived from operator expertise.
  • Action Prioritization: Identifies and scores relevant corrective actions (line reconnections, disconnections, node splitting/merging).
  • Modular Structure: Organized code for better maintainability and testing.

Installation

  1. Clone the repository:

    git clone https://github.com/marota/Expert_op4grid_recommender.git
    cd Expert_op4grid_recommender
    
  2. Recommended: Create a virtual environment:

    python -m venv venv
    source venv/bin/activate  # On Windows use `venv\Scripts\activate`
    
  3. Install the package and dependencies:

    • Core dependencies: Make sure you have the necessary libraries installed. If alphaDeesp or specific grid2op versions are not on PyPI, you might need to install them manually first according to their own instructions.
    • Install this package: For development (recommended), use editable mode:
      pip install -e .
      
      Or for a standard installation:
      pip install .
      
    • Install test dependencies (optional):
      pip install -e .[test]
      

Usage Example

Configure the desired scenario in expert_op4grid_recommender/config.py (Date, Timestep, Contingency Lines, etc.).

Then, run the main analysis script from the project root directory:

python expert_op4grid_recommender/main.py --date 2024-08-28 --timestep 36 --lines-defaut FRON5L31LOUHA P.SAOL31RONCI

The script will:

  1. Set up the Grid2Op environment.
  2. Simulate the specified contingency.
  3. Build and save an overflow graph visualization in the Overflow_Graph/ directory.
  4. Apply expert rules to filter actions loaded from the action space file.
  5. Identify and print a list of prioritized corrective actions.

An option that can be activated for specific use is to rebuild an action space from one segmentation of a grid to another or the full grid:

python expert_op4grid_recommender/main.py --rebuild-actions --repas-file allLogics.json --grid-snapshot-file data/snapshot/pf_20240828T0100Z_20240828T0100Z.xiidm

From all known logics on the full grid, and targeted action ids in the ACTION_FILE, it rebuilds the actions to be applied on the grid snapshot (in detailed topology format with switches) at the date of interest.

Configuration

Key parameters can be adjusted in expert_op4grid_recommender/config.py:

  • DATE, TIMESTEP, LINES_DEFAUT: Define the specific case to analyze.
  • ENV_FOLDER, ENV_NAME: Specify the Grid2Op environment location.
  • ACTION_FILE_PATH: Path to the JSON file containing the action space.
  • USE_DC_LOAD_FLOW: Set to True to use DC power flow if AC flow fails.
  • PARAM_OPTIONS_EXPERT_OP: Thresholds and parameters for the overflow graph analysis.

Dependencies

This project relies on several external libraries, including:

  • numpy
  • pandas
  • networkx
  • pypowsybl
  • grid2op (Ensure you have a compatible version installed)
  • alphaDeesp (Ensure this library is installed in your environment)
  • expertop4grid>=0.2.8

See pyproject.toml for the full list.


Testing

To run the unit and integration tests, navigate to the project root and use pytest:

pytest

Note: Some integration tests (@pytest.mark.slow) require the Grid2Op environment data to be present and may take longer to run.


License

This project is licensed under the Mozilla Public License 2.0 (MPL 2.0). See the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

expert_op4grid_recommender-0.1.1.post2.tar.gz (178.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

expert_op4grid_recommender-0.1.1.post2-py3-none-any.whl (148.8 kB view details)

Uploaded Python 3

File details

Details for the file expert_op4grid_recommender-0.1.1.post2.tar.gz.

File metadata

File hashes

Hashes for expert_op4grid_recommender-0.1.1.post2.tar.gz
Algorithm Hash digest
SHA256 0be2a7df728ab2c830cc11811e9600834ec63cd0e70060df351cc90a3c78df09
MD5 e1c63c11dad86053dff33ec9d2b49bab
BLAKE2b-256 d31a93d9d23d23e4a0fbdae71f4fec4e4c5b489864a20bdcde2a2b0d1a1a8b12

See more details on using hashes here.

Provenance

The following attestation bundles were made for expert_op4grid_recommender-0.1.1.post2.tar.gz:

Publisher: python-publish.yml on marota/Expert_op4grid_recommender

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file expert_op4grid_recommender-0.1.1.post2-py3-none-any.whl.

File metadata

File hashes

Hashes for expert_op4grid_recommender-0.1.1.post2-py3-none-any.whl
Algorithm Hash digest
SHA256 0a8fc446a11c3f20d6f63c23ab0aa5c12af55cb9b561856cdfa7ec1825cda220
MD5 884c2d9fca4a5404f25206176d6a5190
BLAKE2b-256 75afb10cea9757fcd64a5622f8b12e1006c14475b9adf7caa493603e5da60890

See more details on using hashes here.

Provenance

The following attestation bundles were made for expert_op4grid_recommender-0.1.1.post2-py3-none-any.whl:

Publisher: python-publish.yml on marota/Expert_op4grid_recommender

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page