Skip to content
OpenModelicaPublic

About

A Python interface to OpenModelica communicating via ZeroMQ

Resources

Stars

156 stars

Watchers

21 watching

Forks

Repository files navigation

OMPython License: OSMC-PL-RT

OMPython is a Python interface that uses ZeroMQ to communicate with OpenModelica.

Test PyPI Version Conda Version

Dependencies

  • Python >= 3.10; Python >= 3.12 for OMPath functionality (handle file system access via OMC using a pathlib.Path compatible abstraction layer)
  • Additional packages: numpy, psutil, pyparsing and pyzmq

Selecting the OpenModelica installation

OMCSessionLocal and ModelicaSystemOMC look for OpenModelica in this order:

  1. the omhome argument: OMPython.OMCSessionLocal(omhome="C:/Program Files/OpenModelica1.27.0-64bit")
  2. the version argument: OMPython.OMCSessionLocal(version="1.27.0"), or version="1.27" for the newest installed 1.27.x
  3. the environment variable OPENMODELICAHOME
  4. the newest version found in the environment variables OPENMODELICAHOME_<version>
  5. omc on the PATH

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

Installation using pip is recommended.

Via pip

pip install OMPython

Via conda

OMPython is also available as a conda package via conda-forge

conda install -c conda-forge ompython

See the ompython-feedstock for details.

Via source

Clone the repository and run:

cd <OMPythonPath>
python -m pip install -U .

Usage

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.

Bug Reports

Development

It is recommended to set up pre-commit to automatically run linters:

# cd to the root of the repository
pre-commit install

License

This project is licensed under the OSMC Public Runtime License. See LICENSE for details.

Contact

About

A Python interface to OpenModelica communicating via ZeroMQ

Resources

Stars

156 stars

Watchers

21 watching

Forks

Releases

Packages

Used by

Contributors

Languages