Simulate dynamic systems expressed in block diagram form using Python
Block diagram simulation
This Python package enables modelling and simulation of dynamic systems conceptualized in block diagram form, but represented in terms of Python class and method calls. Unlike Simulink or LabView we write Python code rather than drawing boxes and wires. Wires can communicate any Python type such as scalars, lists, numpy arrays, other objects, and even functions.
We first sketch the dynamic system we want to simulate as a block diagram, for example this simple first-order system
which we can express concisely with bdsim
as (see bdsim/examples/eg1.py
1 #!/usr/bin/env python3
2
3 import bdsim
4
5
6 sim = bdsim.BDSim(animation=True) # create simulator
7 print(sim)
8 bd = sim.blockdiagram() # create an empty block diagram
9
10 # define the blocks
11 demand =