OMPython is a Python interface that uses ZeroMQ to communicate with OpenModelica.
- Python 3.x supported
- PyZMQ is required
Installation using pip is recommended.
pip install OMPythonClone the repository and run:
cd <OMPythonPath>
python -m pip install -U .
Running the following commands should get you started
import OMPython
help(OMPython)from OMPython import OMCSessionZMQ
omc = OMCSessionZMQ()
omc.sendExpression("getVersion()")or read the OMPython documentation online.
The workshop/ directory contains comprehensive tutorial examples demonstrating OMPython usage:
Demonstrates heat transfer simulation using Newton's Law of Cooling.
Scripts:
test_basic.py- Basic test and verificationsimple_example.py- Simple visualizationsimulate_cooling.py- Parameter studyinteractive_explorer.py- Interactive dashboard
Quick Start:
cd workshop/cooling
pip install -r requirements.txt
python3 test_basic.pySee workshop/cooling/README.md for details.
SMR (Small Modular Reactor) power plant simulation with thermal-to-electric conversion.
Scripts:
test_basic.py- Basic SMR simulation testvisualize_smr.py- Comprehensive visualizations (4-panel analysis, energy flow, transient response)parameter_study.py- Parameter sweeps and sensitivity analysisinteractive_dashboard.py- Real-time interactive control
Quick Start:
cd workshop/smr
pip install -r requirements.txt
python3 test_basic.py
python3 visualize_smr.py # Generates 3 visualization plotsSee workshop/smr/README.md for details.
Model Equations:
dT_core/dt = (Q_fission - Q_transfer) / (m_coolant * Cp)
Q_transfer = UA * (T_core - T_steam)
P_electric = Q_transfer * eff_thermal
- 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 install- Adeel Asghar, adeel.asghar@liu.se
- Arunkumar Palanisamy, arunkumar.palanisamy@liu.se