Python Electrical Machine Modelling in ONELAB
PyEMMO is a interface for modeling electrical machines in the open-source FEA software ONELAB. The goal of the project is to automate model creation and the simulation workflow for electrical machines with ONELAB.
Use the package manager pip to install PyEMMO.
pip install pyemmoYou will need versions of Gmsh and GetDP executables. While Gmsh can be directly installed from pip with the Gmsh Python-API, you will need to download GetDP individually.
Warning
Models created with PyEMMO fail with current GetDP version 3.6.0 due to mesh import error!
You can check your GetDP version with getdp --version
The easiest way to start is by using the PYLEECAN project to create a electrical machine instance and feeding it into the PyEMMO-PYLEECAN interface.
- Have a look at the PYLEECAN tutorials on how to use PYLEECAN. Especially the tutorial on "How to define a machine".
- See the PYLEECAN API tutorial for detailed instructions on how to create a ONELAB model from a PYLEECAN machine object.
- See the PyEMMO documentation for details.
Here is a small example of the PYLEECAN API:
from os.path import join
from pyemmo.api.pyleecan import main as pyleecan_api
from pyleecan.definitions import DATA_DIR
from pyleecan.Functions.load import load
# load a pyleecan machine
IPMSM_A = load(join(DATA_DIR, "Machine", "Toyota_Prius.json"))
# Run the main function of the pyleecan api:
pyemmo_script = pyleecan_api.main(
pyleecan_machine=IPMSM_A,
model_dir="./Toyota_Prius_ONELAB", # path for the model files
use_gui=True, # select if you want to open the final model in Gmsh.
gmsh="", # optional gmsh executable.
# If use_gui is True, pyemmo will try to find a Gmsh executable on your computer.
getdp="", # optional getdp executable. For simulation in the GUI.
)Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
After cloning the repository you should install pre-commit package using pip install pre-commit.
After that please update the INSTALL_PYTHON path in the pre-commit hook under "./workingDirectory/pre-commit".
Then run the following command to install the Git hooks:
./workingDirectory/install-hooks.shOr if you are on Windows:
install-hooks.batThese hooks make sure you have formatted your files correctly.
- Thanks to all contributors who helped improve this project.
- This project has received funding from the Bavarian Ministry of Economic Affairs, Regional Development and Energy through the TherCom research project. Special thanks to Siemens Electric Motor Plant Bad Neustadt a. d. Saale for supporting it.
To create or update the documentation you will need to do:
- Install the doc requirements with:
pip install -r requirements-doc.txt. - Make sure pyemmo is found by either creating a pyemmo.pth file in the site-packages folder or use
pip install -e .. - To fully build the documentation including the PYLEECAN api subpackage you need to install PYLEECAN. Currently we have to use the Github version since there is no new release yet:
pip install git+https://gitlab.com/Eomys/pyleecan/tree/update-python-version.git - Run Sphinx to build the docs e.g. in html
doc\make.bat html.
You can run doc\make.bat plane to see the build options.
Further information on building the documentation can be found in the Sphinx documentation.
