• Stars
    star
    182
  • Rank 211,154 (Top 5 %)
  • Language Modelica
  • License
    GNU General Publi...
  • Created over 4 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

OpenModelica Microgrid Gym (OMG): An OpenAI Gym Environment for Microgrids

OpenModelica Microgrid Gym

build cov     python pypi download     license
https://github.com/upb-lea/openmodelica-microgrid-gym/raw/develop/docs/pictures/omg_flow.png

The OpenModelica Microgrid Gym (OMG) package is a software toolbox for the simulation and control optimization of microgrids based on energy conversion by power electronic converters.

The main characteristics of the toolbox are the plug-and-play grid design and simulation in OpenModelica as well as the ready-to-go approach of intuitive reinfrocement learning (RL) approaches through a Python interface.

The OMG toolbox is built upon the OpenAI Gym environment definition framework. Therefore, the toolbox is specifically designed for running reinforcement learning algorithms to train agents controlling power electronic converters in microgrids. Nevertheless, also arbritary classical control approaches can be combined and tested using the OMG interface.

Video Tutorial

Following is a short YouTube video introduction, to get a fist impression how to use OMG.

Installation

Install Python Environment

This is the short installation guide for Windows and Linux. OpenModelica is hardly supported for Mac, they suggest to install in a Linux VM. For this reason, running OMG in a Linux VM is strongly recommended for Mac users!

Since it is not possible to install PyFMI, a package which is necessary for the communication between the python interface and the environment, via pip, we recommend to install this package in advance in a conda environment. As of now, only Windows and Linux are supported officially.

  • If conda is NOT installed on your PC, install miniconda for python 3.8

  • Create a new conda environment (e.g. in PyCharm)

  • Install PyFMI from the conda-forge channel in the terminal:

    $ conda install -c conda-forge pyfmi
    
  • Install OpenModelica MicrogridGym from PyPI (recommended):

    $ pip install openmodelica_microgrid_gym
    

Installation of OpenModelica

OMG was create by using OMEdit v1.16

In case of installation issues you can resort to their pre-built virtual machine.

Getting started

The environment is initialized and run like any other OpenAI Gym

import gym

if __name__ == '__main__':
    env = gym.make('openmodelica_microgrid_gym:ModelicaEnv-v1',
               max_episode_steps=None,
               net='../net/net.yaml',
               model_path='../omg_grid/grid.network.fmu')

    env.reset()
    for _ in range(1000):
        env.render()
        env.step(env.action_space.sample())  # take a random action
    env.close()

OMG uses the FMI standard for the exchange of the model between OpenModelica and Python.

An example network consisting out of two inverters, three filters and an inductive load.

https://github.com/upb-lea/openmodelica-microgrid-gym/raw/master/docs/pictures/omedit.jpg

You can either use one of the provided FMUs (Windows and Linux, 64-bit, both included in the grid.network.fmu) or create your own by running:

openmodelica_microgrid_gym\fmu> omc create_fmu.mos

Windows users might need to open the terminal out of OpenModelica by clicking 'tools' => 'OpenModelica Command Prompt' to make sure that the command 'omc' gets recognized.

Running the staticctrl.py starts a simulation with a manually tuned cascaded PIPI controller

https://github.com/upb-lea/openmodelica-microgrid-gym/raw/master/docs/pictures/control.jpg

A save Bayesian approach of a reinforcement learning agent is provided under examples/berkamkamp.py.

https://github.com/upb-lea/openmodelica-microgrid-gym/raw/master/docs/pictures/kp_kp_J.png

Using pytest

OMG provides a big range of tests to ensure correct working toolbox after changes are done. On some windows machines, the tests can only be started from the terminal via 'pytest'.

The standard test OS for the development is Linux. In some cases, we have noticed that the test_modelica.py on windows PCs might throw an error. Since on Linux everything works fine, it seems to be a numerical issue connected with the FMUs.

Citation & white paper

Please find a white paper on the OMG toolbox including an exemplary usage scenario here:

Please use the following BibTeX entry for citing us:

@article{OMG-code2020,
    title = {OMG: A Scalable and Flexible Simulation and Testing Environment Toolbox for Intelligent Microgrid Control},
    author = {Stefan Heid and Daniel Weber and Henrik Bode and Eyke Hüllermeier and Oliver Wallscheid},
    year = {2020},
    doi = {10.21105/joss.02435},
    url = {https://doi.org/10.21105/joss.02435},
    publisher = {The Open Journal},
    volume = {5},
    number = {54},
    pages = {2435},
    journal = {Journal of Open Source Software}
}

@article{OMG-whitepaper2020,
    title={Towards a Scalable and Flexible Simulation and
           Testing Environment Toolbox for Intelligent Microgrid Control},
    author={Henrik Bode and Stefan Heid and Daniel Weber and Eyke Hüllermeier and Oliver Wallscheid},
    year={2020},
    eprint={http://arxiv.org/abs/2005.04869},
    archivePrefix={arXiv},
    primaryClass={eess.SY}
}

Contributing

Please refer to the contribution guide.

Credits

This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.

More Repositories

1

reinforcement_learning_course_materials

Lecture notes, tutorial tasks including solutions as well as online videos for the reinforcement learning course hosted by Paderborn University
Jupyter Notebook
935
star
2

Inkscape_electric_Symbols

Electrical symbol library for the vector graphics program Inkscape.
381
star
3

gym-electric-motor

Gym Electric Motor (GEM): An OpenAI Gym Environment for Electric Motors
Python
294
star
4

awesome-open-source-power-electronics

Lists open source power electronic tools
185
star
5

FEM_Magnetics_Toolbox

An Open-Source FEM Magnetics Toolbox for Power Electronic Magnetic Components
Python
63
star
6

transistordatabase

A unified software engineering tool for managing and evaluating power transistors
Python
48
star
7

ElectricGrid.jl

A time domain electrical energy grid modeling and simulation tool with a focus on the control of power electronics converters
Julia
32
star
8

control-block-diagram

Python Toolbox to draw Control Block Diagrams
Python
17
star
9

meta_RL_PMSM

Meta Reinforcement Learning-Based CurrentControl of Permanent Magnet Synchronous MotorDrives for a Wide Range of Power Classes
Python
16
star
10

PSOAS

Particle Swarm Optimization Assisted by Surrogates
Python
13
star
11

transistordatabase_File_Exchange

Data exchange for transistor objects generated and managed with Transistor_Database
Python
11
star
12

OpenModelica_Microgrids

OpenModelica_Microgrids is a library to simulate three phase AC Microgrids. Usable as stand-alone version or part of the toolbox OpenModelica Microgrid Gym (https://github.com/upb-lea/openmodelica-microgrid-gym).
Modelica
10
star
13

gem-control

Python
10
star
14

materialdatabase

A database for ferrite core materials to store datasheet information and self-measured data.
Jupyter Notebook
9
star
15

hardcore-magnet-challenge

Winning solution to the IEEE PELS MagNet challenge 2023 (1st Place Model Performance Category)
Jupyter Notebook
9
star
16

thesis_latex_template

LaTeX template for writing a report or thesis at LEA.
TeX
8
star
17

mag-net-hub

MagNet Toolkit - Certified Models of the MagNet Challenge
Python
8
star
18

KiClearance

Generate clearance rules for KiCAD by a human-readable easy-to-use table.
Python
7
star
19

pySignalScope

Processing and comparison of time domain data similar to oscilloscopes in electronics.
Python
6
star
20

LCB-CCB-01_LEA_Control_Board

Control board for power electronics usage.
5
star
21

pygeckocircuits2

A Python wrapper for GeckoCIRCUITS.
Python
5
star
22

ConverterSweepStore

Python
5
star
23

LEA_KiCad_Library

LEA KiCad library for own projects
4
star
24

LCB-Software

Software examples for LEA Control Board (LCB)
C
2
star
25

LCB-CBB-01_Bus_Board

Bus board for the LEA Control Board (LCB).
2
star
26

LCB-CPB-01_Pin_Board

Pin board for LEA control board
2
star
27

HCT_heat_sink_computation_toolbox

Calculate and optimize fan cooled heat sink systems for power electronics converters.
Python
2
star
28

LCB-CTB-01_Test_Board

Test board for the LEA Control Board (LCB).
2
star