A package for electric machinery analysis.
Project description
emachinery
A package for analysis of electric machinery.
[A]. Functions
1. Machine Quantities Calculations & Conversion
2. PI Regulator Tuner based on Texas Instruments' InstaSPIN
3. Run C-based Numerical Integration Simulation
4. Sweep Frequency Analysis
5. Run Python- and Numba-based Realtime Numerical Integration Simulation
6. FEA based Machine Design and Multi-Objective Optimization (develop)
7. PC User GUI for Serial Communication to DSP (develop)
[B]. Installation and Requirements
The package can be installed via pip.
pip install emachinery
To make it work, one needs to take care of the dependencies, which will be detailed below.
The package requires the following free softwares to work as expected:
- gcc (comes with Minimalist GNU for Windows---See this awesome page for info)
- gmake.exe (I use the one from TI's CCS, it is located at somewhere like:
D:\ti\ccs930\ccs\utils\bin\gmake.exe
. Anyway, I decided to just copy-paste gmake.exe to/emachinery/acmsimc/c/gmake.exe
. So no need to install CCS anymore.)- It also works with CMake with some minor modification.
- pip install
- [Optional, to view .ui file] Qt Designer
A list of python dependency is as follows (tested with Python 3.9.5):
backcall==0.2.0
colorama==0.4.4
commonmark==0.9.1
control==0.9.0
cycler==0.10.0
decorator==5.0.9
-e git+git@github.com:horychen/emachinery.git@6f0ec0d034836bb9ab697d3e341ce6967b8514bd#egg=emachinery
ipykernel==5.5.5
ipython==7.24.1
ipython-genutils==0.2.0
jedi==0.18.0
jupyter-client==6.1.12
jupyter-core==4.7.1
kiwisolver==1.3.1
llvmlite==0.36.0
matplotlib==3.4.2
matplotlib-inline==0.1.2
numba==0.53.1
numpy==1.20.3
pandas==1.2.4
parso==0.8.2
pickleshare==0.7.5
Pillow==8.2.0
prompt-toolkit==3.0.18
Pygments==2.9.0
pyparsing==2.4.7
PySide2==5.15.2
python-dateutil==2.8.1
pytz==2021.1
pywin32==301
pyzmq==22.1.0
qtconsole==5.1.0
QtPy==1.9.0
rich==10.2.2
scipy==1.6.3
shiboken2==5.15.2
six==1.16.0
tornado==6.1
traitlets==5.0.5
typing-extensions==3.10.0.0
wcwidth==0.2.5
Save the above list as a file named, e.g., req.txt
.
I recommend to use virtual env, e.g., on Windows prompt:
pip install virtualenv
virtualenv .my_venv
cd .my_venv/Scripts && activate
pip install -r req.txt
pip install --upgrade emachinery
emy
Command emy
is an entry point for starting the main program of this package, which is equivalent to python guiv2/main.py
[C]. Simulation Tips
- Field oriented control is an asymptotic input-output linearizing (IOL) control. This means the IOL is achieved only when flux modulus is regulated to its reference. So before motor starts, we must wait for the motor to build up its magnetic air gap field or else the starting transient would be disturbed. Refer to the figure below.
- The inductance of the motor matters. For a small "DC" servo PM motor, the inductance is relatively designed to be low because the DC source is usually only 24 V or 48 V. However, an induction motor usually has higher inductance, which limits the bandwidth of the current loop, I think. For example, this is what happens to d-axis current regulation when I set desired velocity loop bandwidth from 50 Hz up to 100 Hz. Refer to the figure below.
[D]. Known Issues
GNU Make failed to create process
After adding installing CCS and MinGW, you might need to restart the PC.
gcc -o main pmsm_comm.c im_controller.c ... -I. -L.
process_begin: CreateProcess(NULL, gcc -o main pmsm_comm.c im_controller.c... -I. -L., ...) failed.
make (e=2): The system cannot find the file specified.
makefile:11: recipe for target 'main' failed
gmake: *** [main] Error 2
See this question
Anaconda3 Python Version
Anaconda3 (Python 3.8) comes with qtconsole now, but it will cause problems. My code was developed with Anaconda3 (Python 3.7).
One silly fix is to revert back to Python 3.7 for now:
conda install python=3.7 anaconda=custom
However, it seems upgrade jupyterlab would fix this issue:
pip install --upgrade jupyterlab
Jupyterlab/Qtconsole Version
After I upgrade my jupyterlab to version 3, qtconsole (version 4.6.0) starts to not work well. Below is some error message.
Traceback (most recent call last):
File "D:\DrH\Codes\emachineryTestPYPI\emachinery\gui\main.py", line 947, in <module>
main()
...
...
...
File "D:\DrH\Codes\emachineryTestPYPI\emachinery\gui\consolewidget.py", line 31, in __init__
self.kernel_client = kernel_client = self._kernel_manager.client()
File "D:\Users\horyc\Anaconda3\lib\site-packages\qtconsole\base_frontend_mixin.py", line 63, in kernel_client
if kernel_client.channels_running:
File "D:\Users\horyc\Anaconda3\lib\site-packages\jupyter_client\client.py", line 141, in channels_running
self.control_channel.is_alive())
File "D:\Users\horyc\Anaconda3\lib\site-packages\jupyter_client\client.py", line 200, in control_channel
socket, self.session, self.ioloop
TypeError: ChannelABC() takes no arguments
I found a related discussion here: https://github.com/jupyter/jupyter_client/issues/523 Reading the webpage, I fix this problem by first uninstalling ipykernel and install it back to a higher version.
pip uninstall ipykernel
Found existing installation: ipykernel 5.1.4
Uninstalling ipykernel-5.1.4:
pip install ipykernel
Collecting ipykernel
Downloading ipykernel-5.4.2-py3-none-any.whl (119 kB)
[E] Other Information
This package is published to PYPI following https://www.youtube.com/watch?v=Qs91v2Tofys
Changelog
1.2.3
- Fix bugs when calling acmsimpy from app_functions.py.
1.2.2
- Fix bugs when setting the path to acmsimc.
1.2.0
- Mordern GUI in dark theme by Wanderson.
- Top level global variable CTRL, which is a struct of pointers to other structs.
1.1.5
- Recover last user selected MachineName and MachineType.
1.1.4
- Anaconda3 (Python 3.8) comes with qtconsole now, but it will cause problems.
My code was developed with Anaconda3 (Python 3.7). So one silly fix is to revert back to Python 3.7 for now:
conda install python=3.7 anaconda=custom
But before you try to revert, trypip install --upgrade jupyterlab
first.
1.1.3
- No use of LoadUi when published.
1.1.2
- Support parametric analysis.
1.1.1
- User is now able to select from different plot settings.
- Support sinusoidal flux modulus command for induction motor.
- Remember user's last selected plot setting considering machine types, i.e., IM or PMSM.
- Marino05 is tuned.
1.1.0
- Induction motor simulation.
- Marino05 is added.
- Harnefors06 is tuned for a different motor.
- Fix the bug "cannot file .dat file" when "Plot Here" is clicked upon start.
1.0.9
- (Video@Bilibili) Demonstrate the effectiveness of the current loop decoupling (PMSM).
- Allow velocity-open-loop and current-closed-loop for sweep frequency analysis.
- Automatically add path2acmsimc if the user-specified path does not exist.
- Remember last user input for C-based simulation.
1.0.8
- I was stupid. Version 1.0.7 did not do its job.
1.0.7
- Add the resource "makefile" to the package.
1.0.6
- Remember last user input for path2acmsimcv5 and add config.json to gui/
- Publish acmsimcv5 along with the package.
1.0.5
- Add sweep-frequency and bode-plot feature.
- gmake compile .c program, execute .exe, collect .dat, and ggplot.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for emachinery-1.2.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7051e3d4a8cf65faa7c9863d6387e9431957de0c5bc9c462cccce2e7304427f8 |
|
MD5 | c2f422c9b7c1e7453e8fda47fcbbe835 |
|
BLAKE2b-256 | 47411e771137e91380016dbb03cb779eafa3191dc11ae1c05b877d4b2dd81072 |