Metadata-Version: 2.4
Name: Grid2Env
Version: 0.0.1
Summary: A tool for creating new Grid2Op Eenvironments.
Author-email: Xavier Weiss <xavierw@kth.se>
Maintainer-email: Xavier Weiss <xavierw@kth.se>
Project-URL: Homepage, https://github.com/DEUCE1957/Grid2Env
Project-URL: Repository, https://github.com/DEUCE1957/Grid2Env
Project-URL: Issues, https://github.com/DEUCE1957/Grid2Env/issues
Project-URL: Documentation, https://grid2env.readthedocs.io/
Keywords: synthetic,ML,powergrid,optimization,RL,power-systems
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: OS Independent
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Education
Classifier: Intended Audience :: Science/Research
Classifier: Natural Language :: English
Classifier: Operating System :: POSIX :: Linux
Classifier: Operating System :: Microsoft :: Windows
Classifier: Topic :: Scientific/Engineering
Classifier: Topic :: Utilities
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE.md
License-File: AUTHORS.txt
Requires-Dist: grid2op
Requires-Dist: chronix2grid
Requires-Dist: PyQt6
Requires-Dist: click
Requires-Dist: pypsa
Requires-Dist: numba
Requires-Dist: docstring_parser
Provides-Extra: docs
Requires-Dist: sphinx; extra == "docs"
Requires-Dist: sphinx_rtd_theme; extra == "docs"
Requires-Dist: ipykernel; extra == "docs"
Requires-Dist: nbsphinx; extra == "docs"
Requires-Dist: sphinx-collections; extra == "docs"
Dynamic: license-file

# Grid2Env
Tool for creating new [Grid2OP](https://github.com/rte-france/Grid2Op) environments using the [Chronix2Grid](https://github.com/BDonnot/ChroniX2Grid) library.

![Grid2Env Workflow](media/Grid2Env.svg)

Features:
- Load any PandaPower network and generate load, solar, wind and dispatch timeseries for it.
- Generate extreme events (N-k) line outages, to create more challenging, resilience-oriented episodes / scenarios (optional)
- Enhance network with energy storage, sized according to the size of the loads they are located alongside.

## Installation
See the documentation for more details.

By default, Grid2Env is best used from a clone of the Grid2Env repository. 
```bash
git clone git@github.com:DEUCE1957/Grid2Env.git
cd Grid2Env
...
```
Once you are happy with your generated environment, you can copy it over to your Grid2Op environment directory for actual use (e.g. for a training a reinforcement learning agent).

You can also install as a standalone Python package:
```bash
pip install grid2env
...
```

## Usage (Command Line Interface)
```python
python grid2env --env cigre_mv --network cigre_network_mv --n_scenarios 365 --gap 1 --scenario_length 28 --extreme 2 --verbosity info
```
Will generate 365 scenarios in Grid2Op's local directory (changed using '''grid2op.change_local_dir(PATH)'''). Each scenario will be 28 days long, with its start date offst by 1 day from the previous scenario. This means there will be 27 days overlap with the previous scenario, though the actual timeseries will be different. Each scenario will have between 1 and 2 (upper limit) random components disabled, representing an extreme initial event that the RL agent must recover from.

The script will look for a .json file called 'cigre_network_mv.json' in the '.../Grid2Env/Networks/' folder which represents a PandaPower grid. Since 'cigre_network_mv' also matches a function called 'create_cigre_network_mv' in PandaPower, the network will be 'fetched' automatically.

To create the network manually, simply do the following:
```python
import pandapower as pp
network = pp.networks.create_cigre_network_mv(with_der="pv_wind")
network.to_json("cigre_mv.json") # Put this in '.../Grid2Env/Networks/cigre_mv.json'
```
The Jupyter Notebook 'PandaPowerNetworks.ipynb' provides some more examples of built-in PandaPower networks.

The script cli.py is the recommended / most-up-to-date way to generate scenarios.

## Planned Features
Currently Grid2Env does NOT include these features, but it may be expanded in the future to include them:
- Support for networks with multiple external grids / a distributed slack. 
- Support for converting other power system network formates / libraries (PyPowSybl, etc.)
- Reduce dependency on Chronix2Grid

### Known Problems
* **Chronix2Grid** throws error on method `lopf()` or `mremove()`. This is because it was built with an older version of PyPSA. Clone the latest Github repository of [Chronix2Grid](github.com/Grid2op/chronix2grid) and install from there instead of [PyPi](https://pypi.org/project/Chronix2Grid/). Also see [PR #92](https://github.com/Grid2op/chronix2grid) if `mremove()` still throws an error.
* **Numba Warning**: When executing methods in Grid2Env, you may get a numba warning printed. This is hard-coded into PandaPower and cannot be suppressed. The 'Suppresor' content manager in 'utilities.py' can be used to suppress print statements over a block of code.

## Citing
```
@misc{grid2env,
    author = {X. Weiss},
    title = {Grid2Env - Tool for creating new Grid2Op environments using the Chronix2Grid library},
    year = {2026},
    publisher = {GitHub},
    journal = {GitHub repository},
    howpublished = {\url{https://github.com/DEUCE1957/Grid2Env}},
    }
```

## License Information
This source code is subject to the terms of the non-AI Mozilla Public License (MPL) v2, also available [here](https://github.com/non-ai-licenses/non-ai-licenses/blob/main/NON-AI-MPL-2.0).
