Gym Electric Motor
The gym-electric-motor (GEM) package is a versatile Python toolbox designed for the simulation and control of various electric motors. Built upon the foundations of Faram Gymnasium Environments, this package provides a playground for both classical motor control simulation as well as cutting-edge reinforcement learning experiments. By utilizing GEM, users can replicate a standard drive train, incorporating essential elements like supply voltage, converters, electric motors, and load models. This setup facilitates a closed-loop simulation of the physical structure, offering a comprehensive interface for integrating decision-making algorithms—from simple linear feedback control to advanced Deep Deterministic Policy Gradient (DDPG) agents.
Getting Started
To familiarize oneself with GEM, the package offers several interactive notebooks available on Google Colaboratory. These notebooks illustrate the primary features of GEM, accompanied by application demonstrations that are perfect for both industry professionals and academic researchers. Some notable resources include:
For those seeking minimalistic demonstrations, a collection of standalone example scripts is also available.
For a quick jumpstart, the basic implementation is straightforward:
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()) # Execute random actions
if done:
(states, references), _ = env.reset()
env.close()
Installation
Getting GEM set up is simple:
-
Install from PyPI (recommended):
pip install gym-electric-motor
-
Install from GitHub source:
git clone [email protected]:upb-lea/gym-electric-motor.git cd gym-electric-motor # Then choose one of the following python setup.py install # or alternatively pip install -e .
Building Blocks
A GEM environment is composed of several core elements:
- Physical Structure:
- Supply Voltage
- Converter
- Electric Motor
- Load Model
- Utility Functions:
- Reference Generation
- Reward Calculation
- Visualization
Information Flow in a GEM Environment
Available Motor Models
GEM supports simulations with a variety of motor models, including:
- Permanent Magnet Synchronous Motor (PMSM)
- Synchronous Reluctance Motor (SynRM)
- Squirrel Cage Induction Motor (SCIM)
- Doubly-fed Induction Motor (DFIM)
Converters can be controlled via a duty cycle (continuous control set) or switching commands (finite control set).
Citation
For academic use, GEM is discussed in two primary papers. The general toolbox is covered in the Journal of Open Source Software (JOSS), and there's a reinforcement learning paper available on IEEE-Xplore, with its preprint on arxiv.org.
Running Unit Tests with Pytest
To ensure the integrity of the package, unit tests can be executed using 'pytest'. Tests are located in the 'tests' folder. Execute commands in the project's root directory like so:
>>> pytest
Add coverage checking with:
>>> pytest --cov=./
Successful passage of all tests ensures GEM's functionality.