Skip to main content

Gym Electric Motor

Overview paper | Reinforcement learning paper | GEM control paper | Quickstart | Install guide | Reference docs | Release notes

Build Status codecov PyPI version shields.io License DOI Zenodo DOI JOSS

Overview

The gym-electric-motor (GEM) package is a Python toolbox for the simulation and control of various electric motors. It is built upon Farama Gymnasium Environments, and, therefore, can be used for both, classical control simulation and reinforcement learning experiments. It allows you to construct a typical drive train with the usual building blocks, i.e., supply voltages, converters, electric motors and load models, and obtain not only a closed-loop simulation of this physical structure, but also a rich interface for plugging in any decision making algorithm, from linear feedback control to Deep Deterministic Policy Gradient agents. In addition, an automated framework for classical control structures based on PI controllers is provided.

Getting Started

An easy way to get started with GEM is by playing around with the following interactive notebooks in Google Colaboratory. Most important features of GEM as well as application demonstrations are showcased, and give a kickstart for engineers in industry and academia.

There is a list of standalone example scripts as well for minimalistic demonstrations.

A basic routine is as simple as:

import gym_electric_motor as gem

if __name__ == '__main__':
    env = gem.make("Finite-CC-PMSM-v0")  # instantiate a discretely controlled PMSM
    env.reset()
    for _ in range(10000):
        (states, references), rewards, done, _ =\ 
        	env.step(env.action_space.sample())  # pick random control actions
        if done:
            (states, references), _ = env.reset()
    env.close()

Installation

  • Install gym-electric-motor from PyPI (recommended):
pip install gym-electric-motor
  • Install from Github source:
git clone git@github.com:upb-lea/gym-electric-motor.git 
cd gym-electric-motor
# Then either
python setup.py install
# or alternatively
pip install -e .

Building Blocks

A GEM environment consists of following building blocks:

  • Physical structure:
    • Voltage supply
    • Converter
    • Electric motor
    • Load model
  • Utility functions for reference generation, reward calculation and visualization

Information Flow in a GEM Environment

Among various DC-motor models, the following AC motors - together with their power electronic counterparts - are available:

  • Permanent magnet synchronous motor (PMSM)
  • Synchronous reluctance motor (SynRM)
  • Externally excited synchronous motor (EESM)
  • Squirrel cage induction motor (SCIM)
  • Doubly-fed induction motor (DFIM)

The converters can be driven by means of a duty cycle (continuous control set) or switching commands (finite control set).

Citation

A white paper for the general toolbox in the context of drive simulation and control prototyping can be found in the Journal of Open Source Software (JOSS). Please use the following BibTeX entry for citing it:

@article{Balakrishna2021,
    doi = {10.21105/joss.02498},
    url = {https://doi.org/10.21105/joss.02498},
    year = {2021},
    publisher = {The Open Journal},
    volume = {6},
    number = {58},
    pages = {2498},
    author = {Praneeth {Balakrishna} and Gerrit {Book} and Wilhelm {Kirchgässner} and Maximilian {Schenke} and Arne {Traue} and Oliver {Wallscheid}},
    title = {gym-electric-motor (GEM): A Python toolbox for the simulation of electric drive systems},
    journal = {Journal of Open Source Software}
}

A white paper for the utilization of this framework within reinforcement learning is available at IEEE-Xplore (preprint: arxiv.org/abs/1910.09434). Please use the following BibTeX entry for citing it:

@article{9241851,  
  author={Traue, Arne and Book, Gerrit and Kirchgässner, Wilhelm and Wallscheid, Oliver},
  journal={IEEE Transactions on Neural Networks and Learning Systems}, 
  title={Toward a Reinforcement Learning Environment Toolbox for Intelligent Electric Motor Control}, 
  year={2022},
  volume={33},
  number={3},
  pages={919-928},
  doi={10.1109/TNNLS.2020.3029573}}

A white paper for the classical control approaches of gym-electric-motor control is available at IEEE-Xplore. Please use the following BibTeX entry for citing it:

@INPROCEEDINGS{10239044,
  author={Book, Felix and Traue, Arne and Schenke, Maximilian and Haucke-Korber, Barnabas and Wallscheid, Oliver},
  booktitle={2023 IEEE International Electric Machines & Drives Conference (IEMDC)}, 
  title={Gym-Electric-Motor (GEM) Control: An Automated Open-Source Controller Design Suite for Drives}, 
  year={2023},
  volume={},
  number={},
  pages={1-7},
  doi={10.1109/IEMDC55163.2023.10239044}}

Running Unit Tests with Pytest

To run the unit tests ''pytest'' is required. All tests can be found in the ''tests'' folder. Execute pytest in the project's root folder:

>>> pytest

or with test coverage:

>>> pytest --cov=./

All tests shall pass.

Release files for gym-electric-motor 3.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gym-electric-motor 3.0.3
File Size Uploaded
gym_electric_motor-3.0.3.tar.gz 303.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for gym-electric-motor 3.0.3
File Interpreter ABI Platform
gym_electric_motor-3.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 695.5 kB

Release files / gym_electric_motor-3.0.3.tar.gz

Download URL gym_electric_motor-3.0.3.tar.gz
Size 303.4 kB
Tags Source
SHA-256 checksum
How to use checksums
8e02b78b0379b962c362ffce75888cebf3fccfedf55bc84780efa1ee65446ac2
BLAKE2b-256 checksum
How to use checksums
43902d526a1fb062d43ad2b9fe6a8030c084d222cbdf309c647f326f19d0bae0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.9

Release files / gym_electric_motor-3.0.3-py3-none-any.whl

Download URL gym_electric_motor-3.0.3-py3-none-any.whl
Size 392.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ca74242344fa7f1b1395e1aae873d411a297398ee20663a84f55b930abf1dbac
BLAKE2b-256 checksum
How to use checksums
d136e9b57420664e155c1e6773ddeac6373ecb5679738e2e47f2f80b468b12e8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.9

Release history Release notifications | RSS feed

This release

3.0.3 This release

2 release files

3.0.2

2 release files

2.0.0

2 release files

1.1.0

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page