Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OpenModelica-PyQt-Desktop-App

A Python/PyQt6 desktop application that lets you launch and configure any OpenModelica-compiled simulation executable through a clean graphical user interface — no command line required.


Purpose

OpenModelica compiles Modelica models into standalone Windows executables. These executables accept simulation flags (-startTime, -stopTime, etc.) as command-line arguments, which is inconvenient for users who are not familiar with the command line.

This application wraps that workflow in a simple GUI:

  1. Browse to the compiled .exe
  2. Enter a start time and stop time
  3. Click Run Simulation

The app validates all inputs before running, streams the simulation output into the window, and reports success or failure clearly.


Project Structure

OpenModelica-PyQt-Desktop-App/
├── app/
│   ├── __init__.py          # Makes app/ a Python package
│   └── main_window.py       # MainWindow class — all GUI and simulation logic
├── simulation/
│   ├── TwoConnectedTanks.exe
│   ├── TwoConnectedTanks_init.xml
│   └── *.dll                # OpenModelica runtime DLLs (self-contained)
├── main.py                  # Entry point — creates QApplication and shows MainWindow
├── requirements.txt         # Python dependencies
└── README.md

Requirements

Requirement Version
Python 3.6 or higher
PyQt6 6.0 or higher
OS Windows (64-bit)

Note: OpenModelica does not need to be installed on the target machine. All required DLLs are bundled in the simulation/ folder.


Installation

# Clone or download the repository
git clone https://github.com/ekagrazi/OpenModelica-PyQt-Desktop-App.git
cd OpenModelica-PyQt-Desktop-App

# Install the Python dependency
pip install -r requirements.txt

Usage

Launch the application

python main.py

Step-by-step

  1. Browse — Click the Browse button next to the first field and select the OpenModelica-compiled .exe (e.g. simulation/TwoConnectedTanks.exe).

  2. Start Time — Enter an integer ≥ 0 (e.g. 0).

  3. Stop Time — Enter an integer that is greater than Start Time and strictly less than 5 (e.g. 4).

    Constraint: 0 ≤ startTime < stopTime < 5

  4. Run Simulation — Click the ▶ Run Simulation button. The output box displays the command that was run, the simulation output, and a success or error message.

Example — valid run

Field Value
Executable simulation/TwoConnectedTanks.exe
Start Time 0
Stop Time 4

The app constructs and executes:

TwoConnectedTanks.exe -startTime=0 -stopTime=4

Validation rules (shown as error dialogs, app never crashes)

Bad input Error shown
No executable selected "Executable path is empty."
Non-integer start/stop "Start time '...' is not a valid integer."
start ≥ stop "Times must satisfy 0 ≤ start < stop < 5"
stop ≥ 5 "Times must satisfy 0 ≤ start < stop < 5"

Methodology

The application follows a clean MVC-like separation:

  • main.py — bootstrap only (creates QApplication, shows window).
  • app/main_window.py — the MainWindow class encapsulates all GUI construction (_build_ui), input validation (_validate_inputs), file browsing (_browse_executable), and simulation execution (_run_simulation).

Simulation is launched via Python's subprocess.run with:

  • capture_output=True — both stdout and stderr are captured.
  • cwd set to the folder containing the exe — so the exe can find its companion .xml data files next to it.
  • timeout=60 — the run is aborted and an error dialog is shown if the simulation takes longer than 60 seconds.

Technologies

Technology Role
Python 3 Application language
PyQt6 Cross-platform GUI framework
OpenModelica Modelica model compiler / simulation engine
subprocess Launching the simulation executable
Windows 64-bit Target operating system

About

A PyQt6-based desktop application for configuring and running OpenModelica simulation executables.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages