Symbolic Multi-Body Dynamics in Python — An Introduction.

Khaled Ghobashy
7 min readOct 6, 2019

--

INTRODUCTION

The field of Modeling and Simulation is becoming more and more of central importance in many scientific and engineering contexts, as the existence of valuable insights and accurate predictions in a timely manner in the development cycle, can lead to much better products with a much reduced time-to-market and rework.

Those benefits are pushing the companies to better integrate these predictive technologies in their product development cycles and to invest in good simulation software packages, but those benefits comes with a cost too -other than being expensive-.
Eventually, these are just tools, and “a tool is only as good as its user”. Therefore, any sort of misuse of such technologies, either on a high-level process structure, or on a low-level direct usage, can lead to the exact opposite of what was intended.

Increased Complexity Pitfall

The continuous development of more advanced tools capable of producing more sophisticated, high-fidelity models, as well as the increase of computing power, leads to an irresistible temptation to add complexity to these predictive models. This is not always a good thing, as the focus may get shifted towards the model itself, and not the question it tries to answer.

“Models do not possess intrinsic value. They are for solving problems. They should be thought of in relation to the problem or range of problems which they are intended to solve. The ideal model is that with minimum complexity which is capable of solving the problems of concern with an acceptable risk of the solution being ‘wrong’. This acceptable risk is not quantifiable and it must remain a matter of judgement. However, it is clear that diminishing returns are obtained for model elaboration.”

- Sharp (1991)

Ease-of-Use Pitfall

Another pattern that can be noticed, is that the industry is aiming to make simulation more pervasive, by making simulation as something of a ‘commodity’, bought and sold and often used without a great deal of formal comprehension, so it can be usable by non-experts.
This is not a good nor a bad thing by itself, but it requires more care as it becomes more easy to fall in the “garbage in, garbage out” pitfall, due to the lack of knowledge with the underlying formulations used in such tools.

This mode of operation is already becoming established within the analysis groups of large automotive companies where analysts make use of customized software programs. These programs have two distinct types of usage. At one level the software is used by an ‘expert’ with the experience, knowledge and skill to customize the models generated, the types of simulation to be performed and the format in which selected results will be presented. A larger group of ‘standard’ users are then able to use the program to carry out suspension or full vehicle simulations assuming little or no knowledge of multi-body systems formulations and solution methods. [1]

The Link

The introduction was intended to be a bit generic in attempts to give a bigger scoop of the topic, and to express some of my thoughts and motives behind my work. I was a Formula Student (FS) member for more than three years, and my main interest was in suspension system modeling and simulation.

The FSAE/FS competition is considered as an “educational engineering competition”, that provides lots of real-life, hands-on experience that can not be found easily else-where for students. But, in my opinion, the term “educational” some-times gets lost in the journey, and we are left only with the “competition” part. This results in an ill-balanced experience, where most of the students fall in the previously mentioned pitfalls, myself included.

I tried to correct my approach, as a student, and started reading about the underlying theories used in the commercial multi-body systems software packages used in vehicle modeling. And as a way to check my understanding of such topics, I started implementing what I learned in code. And that is how I got down into the rabbit hole, in a good sense.

Now, what I hope is to encourage others to seek and acquire a deeper understanding of the modeling processes and the underlying theories used in other commercial software packages, which is a way of giving back to the FS/FSAE community, and supporting the concept of “knowledge share” adopted there by exposing it to the open-source community as well.

SMBD | Symbolic Multi-Body Dynamics in Python

“ Vehicle performing a lane-change maneuver — The full-vehicle model is created and simulated in SMBD and animated in blender”

SMBD is an open-source python package developed for the creation, simulation and visualization of multi-body systems. The following sections gives a quick introductory overview of the tool.

  1. What is Multi-Body Dynamics?
  2. The Motive, The Audience and The Fields of Applications.
  3. The “questions” to be answered.
  4. How does the tool approaches the problem?
  5. Current capabilities and features.

1- What is Multi-Body Dynamics?

In modern literature, multi-body systems refer to modern mechanical systems that are often very complex and consist of many components interconnected by joints and force elements such as springs, dampers, and actuators. Examples of multi-body systems are machines, mechanisms, robotics, vehicles, space structures, and bio-mechanical systems. The dynamics of such systems are often governed by complex relationships resulting from the relative motion and joint forces between the components of the system. [2]

2- The Motive, The Audience and The Fields of Applications.

Initially, the main targeted audience was the Formula Student community. The motive was to “encourage deeper understanding of the modeling processes and the underlying theories used in other commercial software packages”, which is a way of giving back to the community, and supporting the concept of “knowledge share” adopted there by exposing it to the open-source community as well.
Currently, the tool aims to serve a wider domain of users with different usage goals and different backgrounds, such as students, academic researchers and industry professionals.

Fields of application include any domain that deals with the study of interconnected bodies, such as:

  • Ground Vehicles’ Systems.
  • Construction Equipment.
  • Industrial Mechanisms.
  • Robotics.
  • Bio-mechanics.
  • .. etc.

3- The “Questions” to be answered.

For a given multi-body system, the analyst may face different “questions” that he wish to answer. These questions mainly lie in four categories of analysis. These are:

  1. Kinematic Analysis:
    “How does the whole system move if we moved this particular body?”
  2. Inverse Dynamic Analysis:
    “What are the forces needed to achieve this motion we just did?”
  3. Equilibrium Analysis:
    “How does the system look if we did nothing?”
  4. Dynamic Analysis:
    “Now we gave it a force, how does it behave?”

4- How does the tool approaches the problem?

The main theme of the tool is to isolate the model creation process form the actual numerical and computational representation of the system, that will be used in the simulation process. This is done through the ideas of symbolic computing and code-generation. The tool decomposes the problem into three major steps:

1- Symbolic Topology Creation.
The System Topology is a description of the connectivity relationships between the bodies in a given multi-body system. These relationships represent the system constraints that control the relative motion between the system bodies and produce the desired kinematic behavior.
The tool abstracts the topology of the system as a multi-directed graph, where each node represents a body and each edge represents a connection between the end nodes, where this connection may represents a joint, actuator or a force element. The tool does not take any numerical inputs at that step, it only focuses on the validity of the topological design of the system, and not how it is configured in space.

2- Numerical Environment Generation.
The process of performing actual simulations on the created model requires the generation of a valid numerical and computational representation of the model. This is done by taking in the symbolic model and generate valid code files written in the desired programming language with the desired programming paradigm and structure. The tool provides two numerical environments, one in python and another one in C++.

3- Numerical Simulation.
The final main step is to perform the desired simulations on the generated model. This is where we start giving our model the needed numerical inputs that defines the system configuration in space -bodies’ and joints’ locations and orientations-, as well as the needed actuation functions for the prescribed motions and forces -if exists-.
After the simulation step, we can do any sort of post-processing on the results. The tool also provide an add-on for blender that can be used to visualize and animate the given model.

5- Current capabilities and features.

1- Symbolic Model Creation

  • Creation of symbolic template-based and stand-alone multi-body systems using minimal API via python scripting.
  • Convenient and easy creation of complex multi-body assemblies.
  • Viewing the system’s symbolic equations in a natural mathematical format using Latex printing.

2- Numerical Simulation Environments
The tool aims to provide a full encompassing simulation environments and not only code-generation. The tool currently provides:

  • A numerical simulation environment in python that provides a python solver that can be used to solve for Kinematically and Dynamically Driven Systems using the NumPy and SciPy libraries for numerical evaluation.
  • A numerical simulation environment in C++ that provides a solver that can be used to solve for Kinematically Driven Systems using Eigen library as the linear algebra engine and selected modules from the Boost library for other math functionalities. It also generates appropriate makefiles that automates the build process of model executable.

3- 3D Visualization
A blender add-on that can be easily added to blender’s GUI, to facilitate the visualization process of the simulated systems.

Next Steps

The motive here is, as I mentioned earlier, is to share the knowledge and the experience with others. I hope to do that through several articles discussing high-level multi-body systems design, as well as low-level challenges in the formulations and solution methods. And, hopefully, may be some-day others would be interested to contribute to the development of the tool.

And finally, I would like to share a very thought-provoking quote regarding the topic.

“We have no idea about the ‘real’ nature of things … The function of modeling is to arrive at descriptions which are useful.”

- Richard Bandler and John Grinder, 1979

Thank you for your time.

References

[1] Blundell, M., Harty, D., 2004, The Multibody Systems Approach to Vehicle Dynamics, Elsevier Butterworth-Heinemann, Oxford.

[2] Shabana, A.A., Computational Dynamics, Wiley, New York, 2010.

--

--

Khaled Ghobashy

Automotive Engineer. Experienced in Multi-Body Systems, Computational Dynamics and Object Oriented Programming.