OMPython is a Python interface that uses ZeroMQ to communicate with OpenModelica.
- Python >= 3.10; Python >= 3.12 for
OMPathfunctionality (handle file system access via OMC using apathlib.Pathcompatible abstraction layer) - Additional packages: numpy, psutil, pyparsing and pyzmq
OMCSessionLocal and ModelicaSystemOMC look for OpenModelica in this order:
- the
omhomeargument:OMPython.OMCSessionLocal(omhome="C:/Program Files/OpenModelica1.27.0-64bit") - the
versionargument:OMPython.OMCSessionLocal(version="1.27.0"), orversion="1.27"for the newest installed 1.27.x - the environment variable
OPENMODELICAHOME - the newest version found in the environment variables
OPENMODELICAHOME_<version> omcon thePATH
The Windows installer of OpenModelica allows several versions to be installed side by side and sets
OPENMODELICAHOME_<version> for each of them, with every character of the version that is not a letter or a
digit replaced by an underscore: OPENMODELICAHOME_1_27_0 for version 1.27.0. OPENMODELICAHOME points to the
version selected as the default one.
Installation using pip is recommended.
pip install OMPythonOMPython is also available as a conda package via conda-forge
conda install -c conda-forge ompythonSee the ompython-feedstock for details.
Clone the repository and run:
cd <OMPythonPath>
python -m pip install -U .Running the following commands should get you started
import OMPython
help(OMPython)import OMPython
omc = OMPython.OMCSessionLocal()
omc.sendExpression("getVersion()")or read the OMPython documentation online.
- Submit bugs through the OpenModelica GitHub issues.
- Pull requests are welcome.
It is recommended to set up pre-commit to automatically run linters:
# cd to the root of the repository
pre-commit installThis project is licensed under the OSMC Public Runtime License. See LICENSE for details.
- Adeel Asghar, adeel.asghar@liu.se
- Arunkumar Palanisamy, arunkumar.palanisamy@liu.se