Chronix2Grid is a python package, providing a command-line application as well, that allows to generate synthetic but realistic consumption, renewable production, electricity loss (dissipation) and economic dispatched productions chronics given a power grid. Reference data that you provide will serve to calibrate the parameters so that the synthetic data reproduce some realistic criteria (KPIs) from the reference data.
See the documentation at https://chronix2grid.readthedocs.io/en/latest/
pip3 install -U virtualenv
python3 -m virtualenv venv_chronix2grid
source venv_chronix2grid/bin/activate
pip install Chronix2Grid
source venv_chronix2grid/bin/activate
git clone https://github.com/mjothy/ChroniX2Grid.git
cd ChroniX2Grid/
pip install -U .
A backend for dispatch has been implemented with PyPSA
pip install pypsa==0.17.0
You might need to install cbc solver as well that pypsa will call: https://projects.coin-or.org/Cbc
Four notebooks are provided to get you started with this package:
Additionally, a data starting kit is provided to run an example in the folder
getting_started/example
The output folder corresponds to the following run of chronix2grid :
chronix2grid --mode LRTK --ignore-warnings --weeks 8 --n_scenarios 1 --start-date 2012-01-01 --by-n-weeks 4
NB:
To provide --input-data and --output-folder folders and specify --case grid case, you would run this kind of command (make sure to change ChroniX2Grid_path with you own path) :
chronix2grid --mode RLTK --output-folder ChroniX2Grid_path/getting_started/example/output --input-folder ChroniX2Grid_path/getting_started/example/input --ignore-warnings --weeks 8 --case case118_l2rpn_wcci --n_scenarios 1 --start-date 2012-01-01 --by-n-weeks 4
If you already generated your data such as from a grid2op environment, you can generate KPIs afterwards under this cli given that a paramsKPI.json exists in the input-folder/kpi/grid_case
chronix2grid --mode K --output-folder pathTo/data_grid2op/l2rpn_wcci_2022/chronics --input-folder ChroniX2Grid_path/input_data --ignore-warnings --weeks 4 --case case118_l2rpn_wcci_2022 --n_scenarios 1
In your "chronics" folder, this will create a "kpi" folder with subfolders of KPIs per chronic
In order to limit the size of the output and the running time for this example, chronics are only generated for 8 weeks. This implicates that some kpis that defined on a whole year will not be exploitable for this example.
Usage: chronix2grid [OPTIONS]
Options:
--case TEXT case folder to base generation on
--start-date TEXT Start date to generate chronics
--weeks INTEGER Number of weeks to generate
--by-n-weeks INTEGER Size of the output chunks in weeks
--n_scenarios INTEGER Number of scenarios to generate
--mode TEXT Steps to execute : L(K) for loads only (and KPI);
R(K) for renewables (and KPI) only; LRT (K)
for load, renewable and thermic generation (and KPI);
LRDT(TK) for load, renewable, loss (dissipation) generation
(and thermic and KPI)
--input-folder TEXT Directory to read input files from.
--output-folder TEXT Directory to store output files.
--seed-for-loads TEXT Input seed to ensure reproducibility of loads
generation
--seed-for-res TEXT Input seed to ensure reproducibility of renewables
generation
--seed-for-dispatch TEXT Input seed to ensure reproducibility of dispatch
--ignore-warnings Ignore the warnings related to the existence of
data files in the chosen output directory.
--scenario_name TEXT subname to add to the generated scenario output
folder, as Scenario_subname_i
--nb_core INTEGER number of cores to parallelize the number of
scenarios
--help Show this message and exit.
4 generation submodules and a KPI module are available
The figure below shows how these submodules can be launched together with --mode/-m argument. Note that D and T submodules can't be launched without previous L and R modules, and that KPIs can always been computed
Detailed configuration is made through thematic json files. For instance you will use in the current implementation of Chronix2grid:
Below is an example of params.json which will launch a 5 minutes time step generation, applying a gaussian noise to forecast chronics with a standard deviation of 0.01
{
"dt": 5,
"planned_std": "0.01"
}
Below is an example of params_load.json that provides parameters to correlated generation algorithm.
{
"Lx": 1000,
"Ly": 1000,
"dx_corr": 250,
"dy_corr": 250,
"temperature_corr": 400,
"std_temperature_noise": 0.06
}
You'll find all the details on the parameters used in these json files in the documentation about implemented models
Some general parameters have to be set in INPUT_FOLDER/kpi/paramsKPI.json
Note: if you just want to generate the KPIs from your synthetic data without comparison to reference chronics, you can set
"comparison":null
All generation submodules (LRDT) have a modular backend. You can develop your own load, renewable, loss and dispatch model using as input:
@misc{chronix2grid,
author = {A. Marot, N. Megel, V. Renault, M. Jothy },
title = {{ChroniX2Grid - The Extensive PowerGrid Time-serie Generator}},
year = {2020},
publisher = {GitHub},
journal = {GitHub repository},
howpublished = {\url{https://github.com/BDonnot/ChroniX2Grid}},
}
To launch the unit test suite:
pipenv run python -m pytest tests/unit_tests/ [--verbose -p no:warnings]
To launch integration tests:
pipenv run python -m pytest tests/integration_tests/ [--verbose -p no:warnings]
To launch the Command Line Interface (CLI) test (only if you installed chronix2grid package from Pypi)
pipenv run python -m pytest tests/cli_tests/
You can also analyse the coverage of the tests with coverage and generate an html report:
pip install coverage
coverage run --source=./chronix2grid -m unittest discover
coverage html
This will generate a htmlcov folder containing a static web site with the analysis. Open index.html in a browser to analyse it.