Dynamic System Simulation using Python
Ludo C. Visser, Rob Reilink, Almar Klein
Science Applied v.o.f.
Enschede, The Netherlands
A dynamic system is a system whose behavior depends on its current state, past events and external inputs. Since such systems can be found in practically all research areas, modeling, analysis and simulation of such systems is a task many scientists face regularly.
A common approach to dynamic system modeling is first defining a set of state variables that are deemed to sufficiently describe the state of the systems. Then, a set of differential equations are defined that describe the time evolution of these state variables as a function of the current state of the system and external signals, such as inputs and disturbances. These differential equations can then be (numerically) integrated to obtain time trajectories for the state variables, given an initial state for the system and a given set of external signals. The trajectories that are obtained can then be further analyzed, for example via visualization or statistical analysis.
Usually, a computer is needed for integrating the differential equations and visualizing the results. For this, many options exists, varying from low-level C/C++ implementations to advanced commercial software packages like MATLAB.
In this talk we show how Python can be used for advanced dynamic system simulation, and what the advantages are with respect to other approaches:
1. toolkits like NumPy and SciPy allow to focus on the science instead of implementation
2. being an interpreted language, Python allows rapid model refinement cycles
3. introspection is a powerful tool when debugging model implementations
4. visualization toolkits such as Matplotlib and PyOpenGL provide a diverse ranges of possibilities to visualize the results
5. no license fees
To support this talk, we demonstrate the implementation of a dynamic model, simulation of its behavior by means of numerical integration, and visualization of the results. Only freely available Python packages will be used, illustrating the feasibility of vendor independence in science. Finally, we will discuss which parts in this modeling and simulation process can be improved, and propose how we will realize these improvements.