Skip to main content

A block-diagram simulation environment with PySide6 editor

Project description

pySimBlocks

PyPI version Python License Documentation


A deterministic block-diagram simulation framework for discrete-time modeling, co-simulation and research prototyping in Python.

pySimBlocks allows you to build, configure, and execute discrete-time systems using either:

  • A pure Python API
  • A graphical editor (PySide6)
  • YAML project configuration with exportable Python runner (run.py)
  • Optional SOFA and hardware integration

pySimBlocks graphical editor

Installation

pip install pySimBlocks

Full documentation — user guide, tutorials, and API reference — is available on Read the Docs.

Getting Started

Quick Example

The following example models a simple first-order low-pass filter, defined by the difference equation:

$$ y[k] = \alpha x[k] + (1-\alpha) y[k-1] $$

It can be implemented in pySimBlocks using the following code:

from pySimBlocks import Model, Simulator, SimulationConfig, PlotConfig
from pySimBlocks.blocks.operators import Gain, Sum, Delay
from pySimBlocks.blocks.sources import WhiteNoise
from pySimBlocks.project.plot_from_config import plot_from_config

# 1. Create the blocks
noise = WhiteNoise(name="noise", std=1.0)
delay = Delay(name="delay")
filtered = Sum("filtered", signs="++")
alpha_gain = Gain(name="alpha", gain=0.1)
complement = Gain(name="complement", gain=0.9)

# 2. Build the model
model = Model("Example")
for block in [noise, delay, filtered, alpha_gain, complement]:
    model.add_block(block)

model.connect("noise", "out", "alpha", "in")
model.connect("delay", "out", "complement", "in")
model.connect("alpha", "out", "filtered", "in1")
model.connect("complement", "out", "filtered", "in2")
model.connect("filtered", "out", "delay", "in")

# 3. Simulate the model
sim_cfg = SimulationConfig(dt=0.05, T=30.)
sim = Simulator(model, sim_cfg)
logs = sim.run(logging=["noise.outputs.out", "filtered.outputs.out"])

# 4. Plot the results
plot_cfg = PlotConfig([
    {"title": "Noisy signal vs Filtered",
     "signals": ["noise.outputs.out", "filtered.outputs.out"],},
    ])
plot_from_config(logs, plot_cfg)

The resulting plot should look like this:

Noise filtered

See examples/quick_start/filter.py to run the example yourself.

Graphical Editor

The exact same model can be constructed visually using the graphical editor (as shown in the image above of this README).

To open the graphical editor, run:

pysimblocks gui examples/quick_start/gui

The quick-start GUI project is stored in a single examples/quick_start/gui/project.yaml file.

Learning Resources

Tutorials

Three step-by-step tutorials are available in the documentation:

Tutorial Description
1 Python API Build a closed-loop PI control system in pure Python
2 GUI Build the same system visually with the graphical editor
3 SOFA Replace the plant with a SOFA physics simulation

Other Examples

A collection of basic and advanced examples is available in the examples directory, including:

  • Control system demonstrations
  • SOFA-based simulations (tested with SOFA v24.06 and later.)
  • Hardware and real-time use cases
  • Comparisons with external tools

See examples/README.md for an overview.

Information

License

pySimBlocks is licensed under LGPL-3.0-or-later.


© 2026 Université de Lille & INRIA – Licensed under LGPL-3.0-or-later

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pysimblocks-0.1.1.tar.gz (204.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pysimblocks-0.1.1-py3-none-any.whl (395.2 kB view details)

Uploaded Python 3

File details

Details for the file pysimblocks-0.1.1.tar.gz.

File metadata

  • Download URL: pysimblocks-0.1.1.tar.gz
  • Upload date:
  • Size: 204.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.20

File hashes

Hashes for pysimblocks-0.1.1.tar.gz
Algorithm Hash digest
SHA256 a570124a991be05b910ebc7ffd5ad591768eaba313581cc310ef53036629eb0d
MD5 66aa737a930f207a16dd8c49474e458f
BLAKE2b-256 266de0a0d6b2fd1dc88f025e7ace3e045e6739b5fd4f28ae3c3b71797c16992d

See more details on using hashes here.

File details

Details for the file pysimblocks-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: pysimblocks-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 395.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.20

File hashes

Hashes for pysimblocks-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 becbeeb2675eca08c9f6376e3ad24bf8c2ef94cacf798a4e019f9183ab50b82e
MD5 beaf545fc589c69bd9afc324b5cfa01f
BLAKE2b-256 f61d70cac4a139791b1495f18b03b9dfc552a4ac58e7586e519cf3eda8b62fca

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page