Skip to content

Latest commit

 

History

202 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LegoPST - Lego Power System Technology

Version Platform Language GUI

LegoPST (Lego Power System Technology): A Comprehensive Modeling and Simulation Environment for Process and Control of Complex Energy Systems and Power Plants.

LegoPST provides a robust, modular framework for modeling the complex interactions of thermal, hydraulic, and electrical processes inherent to conventional, nuclear or renewable energy sources generation and distribution networks. Its core strength lies in developing real-time dynamic simulators and high-fidelity models that serve three critical applications:

  1. Operator Training Simulators: Creating immersive training simulator where power plant operators can master both nominal and emergency scenarios in a risk-free setting. The simulator can run transients strictly in real-time but also faster or slower the real-time.
  2. Control System Design & Validation: Designing control strategy, prototyping, testing, and verifying industrial control logic, also in real time, within a realistic virtual environment before live deployment.
  3. Digital Twin Development: Building the "simulation core" of a digital twin for a complete power plant or its key subsystems. These models can run in real-time and can be connected to live plant data for performance monitoring, predictive maintenance, and operational optimization.

✨ Key Features

  • Multi-Physics Static and Dynamic Simulation: Supports thermal, hydraulic, nuclear, RES and electrical processes
  • Modular Environment: Reusable component architecture
  • Graphical Interfaces: MMI (Man-Machine Interface) editor with X11/Motif support
  • Configuration System: Hierarchical management of pages and components
  • Real-Time Simulation: Simulation engine for operator training
  • Integrated CAD: Design tools for process schematics

🏗️ Architecture

Main Components

LegoPST/
├── AlgLib/           # Core algorithm libraries
├── Alg_mmi/          # Man-Machine Interface
├── Alg_rt/           # Runtime System
├── Alg_legopc/       # Models Building Tools
├── lego_big/         # Component libraries
├── kprocedure/       # Administrative scripts
├── docker/           # Docker build and install scripts
├── util97/           # Legacy utilities
├── util2007/         # Other legacy utilities
├── util2025/         # Modern utilities
└── VERSION           # Project version (used by build and installer)

Core Components

AlgLib/ - Core algorithm libraries

  • Contains fundamental libraries (libRt.a, libcom.a, libsim.a, etc.)
  • Threading support via dcethreads
  • Database support via SQLite
  • Shared memory and IPC utilities

Alg_mmi/ - Man-Machine Interface

  • MMI client/server architecture
  • Configuration tools for graphical interfaces
  • Widget libraries and drawing tools
  • Conversion utilities for legacy formats

Alg_rt/ - Runtime System

  • Real-time simulation engine
  • Process control and monitoring
  • Network simulation components
  • Session management

legocad/ - CAD Tools

  • Engineering design tools
  • Model creation and editing
  • Library management for plant components

kprocedure/ - Administrative Scripts

  • System management utilities
  • Process control scripts
  • Database maintenance tools
  • User management and configuration

Key Libraries Structure

  • libcom.a: Communication and event handling
  • libsim.a: Simulation core functions
  • libnet.a: Network communication
  • libipc.a: Inter-process communication
  • libdispatcher.a: Message dispatching system
  • libmanovra.a: Control operations
  • libutil.a: General utilities

Configuration System

The system uses hierarchical configuration:

  1. Environment variables set in .profile_legoroot
  2. Platform detection (32/64-bit Linux)
  3. Extension-based directory structure
  4. User-specific settings in home directories

🚀 Install and Run

The quickest way to run LegoPST is to launch it in a Docker container, without installing the package and without having a machine running the Fedora 41 Linux distribution. In this case the host machine can be a generic Linux distribution running on a X86-64, Intel or AMD platform. Alternatively, if you want a stable installation on your Fedora 41 machine, you can download and install directly into your Fedora.

Option 1: Quick Start - Docker Container Execution

The easiest way to run LegoPST - No installation required! Just Docker and a single command.

Prerequisites

Only Docker is required. Install it on your system:

# Ubuntu/Debian/WSL
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io

# Fedora/RHEL
sudo dnf install -y dnf-plugins-core
sudo dnf config-manager addrepo \
  --from-repofile=https://download.docker.com/linux/fedora/docker-ce.repo
sudo dnf install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin

# Start Docker service
sudo systemctl enable --now docker

# Add your user to docker group (to avoid sudo)
sudo usermod -aG docker $USER
newgrp docker

# Verify installation
docker --version
docker run hello-world
Detailed Docker installation for Fedora 41 / WSL (click to expand)
# Fedora 41 / WSL Docker installation
sudo dnf update
sudo dnf -y install dnf-plugins-core
sudo dnf config-manager --add-repo https://download.docker.com/linux/fedora/docker-ce.repo
sudo dnf install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

# For WSL: Activate systemd
sudo bash -c 'cat >> /etc/wsl.conf << EOF
[boot]
systemd=true
EOF'
# Then restart WSL: wsl --shutdown

sudo systemctl enable --now docker

# Verify
sudo docker run hello-world

LegoPST container installation

Install LegoPST with a single command - this creates the lgrun command:

bash -c "$(curl -fsSL https://raw.githubusercontent.com/RSE-TGM/LegoPST/master/docker/install_legopst_dock.sh)"

This installer:

  • ✅ Downloads the LegoPST Docker launcher
  • ✅ Creates the lgrun command in ~/.local/bin/
  • ✅ Configures your PATH automatically
  • ✅ No need to install LegoPST locally!

After installation, restart your terminal or run:

source ~/.bashrc

Usage

Launch LegoPST with the lgrun command:

# Standard launch (local X11 display)
lgrun

# Launch with demo model included
lgrun --demo

# If you are having trouble with the X11 display, try launching via socat (for SSH/remote connections).
lgrun --socat

# Combine options
lgrun --demo --socat

# Check for updates and pull new Docker image if available
lgrun --pull

# Show all options
lgrun --help

The container automatically:

  • 🚀 Starts Fedora 41 with all LegoPST dependencies
  • 👤 Creates a user matching your host UID/GID
  • 📂 Mounts your home directory as /host_home
  • 🖥️ Configures X11 for graphical applications
  • ⚙️ Sets up a fully configured LegoPST environment

Data Persistence

All your work is saved on the host machine:

  • Models: ~/legopst_userstd/legocad/
  • Simulators: ~/legopst_userstd/sked/
  • Config: ~/defaults/

Data persists even after closing the container.

Option 2: Running into a fully configured linux Fedora 41 distribution

Prerequisites

Fedora 41 running into a :

  • bare-metal
  • virtual machine on-premis or in cloud
  • Windows WSL 2
# Fedora 41 dependencies

sudo dnf update -y && \
sudo dnf install -y --setopt=install_weak_deps=False \
    git \
    gcc gfortran make \
    fastfetch \
    xterm xclock xhost xauth \
    hostname \
    glibc-langpack-en \
    libX11-devel \
    libXmu-devel \
    libXext-devel \
    libXi-devel \
    freeglut-devel \
    motif-devel \
    sqlite-devel \
    libbsd-devel \
    tcl tk tix \
    ncurses-devel \
    mousepad \
    gdbm-devel \
    ksh \
    which \
    procps-ng \
    cpio \
    xdg-open \
    ghostscript \
    drawing \
    evince \
    falkon \
    unix2dos \
    xorg-x11-fonts-misc \
    xorg-x11-fonts-100dpi \
    xorg-x11-fonts-75dpi \
    libXcursor \
    adwaita-cursor-theme && \
sudo dnf clean all

Download LegoPST package and set up user environment

# From the user HOME folder
cd $HOME 
# Clone the repository, git is the prerequisite
git clone https://github.com/RSE-TGM/LegoPST.git
cd LegoPST
source .profile_legoroot # Environment setup
# The environment variable LEGOROOT will be defined as LEGOROOT=$HOME/LegoPST

# For a stable LEGOROOT installation, it is recommend to add LEGOROOT set up to .bashrc with this command:
echo "source $LEGOROOT/.profile_legoroot " >> $HOME/.bashrc

Restart shell session

The system automatically detects:

  • LEGOROOT: Project root path
  • Platform: 32/64-bit Linux detection
  • Compiler flags: gcc/gfortran configuration
  • Database paths: SQLite and threading

Compilation by source

LegoPST is provided as a pre-compiled package, ready for immediate use upon download. For users who wish to customize the software or build from the latest source code, the project can also be fully recompiled. To do so, set up into a fully configured linux Fedora 41 distribution, clone the repository and follow these build instructions.

# Clone the repository
git clone https://github.com/RSE-TGM/LegoPST.git
cd LegoPST

# Setup environment
source .profile_legoroot

# Clean build
make -f Makefile.mk clean
# Full build
make -f Makefile.mk

# Build Docker image (local only)
make -f Makefile.mk docker

# Build Docker image and push to registry
make -f Makefile.mk docker-push

# then go to
# Option 2 - Running in a fully configured Fedora 41

🎮 Usage

Simulator directory structure

cd /home/user/

legocad/
├── libut/         # process modules libraries
├── libut_reg/     # control scheme libraries
|   └── libreg/    # control elementary modules libraries
├── pmod1/         # Process model task
├── reg1/          # Control model task
└── .../           # Other process or control tasks

sked/
├── simul1/        # Simulator configuration
└── .../           # Other simulators

Creating New Models

Launch the Process Model Configurator

cd /home/user/legocad/pmod1
lgpc

Process modeling Main Files

  • *.tom: Model Topology
  • f01.dat: Model internal topology
  • f14.dat: Model data
  • *.a: Object libraries

Launch the Control System Model Configurator

cd /home/user/legocad/reg1
config

Control system modeling Main Files

  • Context.ctx: Control schemes task configuration
  • *.pag: Page resources
  • *.bkg: Graphical backgrounds
  • *.a: Object libraries
  • *.reg: Regulation page

🔧 Simulator Configuration

Simulator Main Files

  • S01: Simulator topology
  • etc:

🏭 Use Cases

  • Operator Training: Power plant simulation
  • System Design: CAD for P&I diagrams
  • Procedure Testing: Operational sequence validation
  • SCADA Training: Advanced operator interfaces

📋 Page Types

  • Synoptic: Overall plant overview
  • Stations: Specific section control
  • Regulation: Automatic control algorithms
  • Teleperm: DCS-type interfaces
  • Library: Reusable component collections

🛠️ LegoPST Development

Build System

  • Recursive Makefiles: Modular build
  • Static Libraries: Optimized linking
  • Version Management: The project version is defined in the VERSION file at the repository root. The build system (Makefile.mk) reads this file and injects the version into all scripts (lgdock, lgrun). The file version.h is auto-generated at build time with git commit hash and build number for C/Fortran code.
  • Cross-compilation: Multi-arch support

Other features

  • pThreads: Compatibility layer
  • Shared Memory: Efficient IPC
  • Message Queues: Asynchronous communication
  • Semaphores: Process synchronization

📊 Data System

  • SQLite: Embedded database
  • XrmDatabase: X11 resource management
  • Binary files: Object serialization
  • Context files: Textual configurations

📜 License

Proprietary - Industrial and educational use

🤝 Contributing

Legacy system under maintenance. Contact maintainer for critical changes.


LegoPST - Powering Industrial Training Since 2010

About

An advanced modular platform for the simulation and control of multi-domain energy processes—covering thermal, hydraulic, and electrical generation and transmission.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages