<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Khaled Ghobashy on Medium]]></title>
        <description><![CDATA[Stories by Khaled Ghobashy on Medium]]></description>
        <link>https://medium.com/@kh.ghobashy?source=rss-6e6ffe47a08c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*alLINjG1YqOfktWkgVnFrA.jpeg</url>
            <title>Stories by Khaled Ghobashy on Medium</title>
            <link>https://medium.com/@kh.ghobashy?source=rss-6e6ffe47a08c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 17:47:32 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@kh.ghobashy/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Multi-Body Dynamics in Python | uraeus.mbd]]></title>
            <link>https://medium.com/@kh.ghobashy/multi-body-dynamics-in-python-uraeus-mbd-d471e4f07049?source=rss-6e6ffe47a08c------2</link>
            <guid isPermaLink="false">https://medium.com/p/d471e4f07049</guid>
            <category><![CDATA[modeling]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[multi-body-dynamics]]></category>
            <category><![CDATA[simulation]]></category>
            <category><![CDATA[uraeus]]></category>
            <dc:creator><![CDATA[Khaled Ghobashy]]></dc:creator>
            <pubDate>Mon, 11 May 2020 19:49:56 GMT</pubDate>
            <atom:updated>2020-05-11T19:49:56.228Z</atom:updated>
            <content:encoded><![CDATA[<p>It’s been a while since our last article <a href="https://medium.com/@kh.ghobashy/symbolic-multi-body-dynamics-in-python-1-system-abstraction-239da62780d7">here</a>, where we discussed how do we abstract the <em>real nature</em> of multi-body systems into some <em>useful descriptions, </em>that can be used to model the systems of interest.</p><p>In this article we will go through a relatively complete example of how to model a simple pendulum in our framework. But before that, we have to take a short detour to keep things tied together.</p><h3>SMBD == URAEUS</h3><p>In the first <a href="https://medium.com/@kh.ghobashy/symbolic-multi-body-dynamics-in-python-an-introduction-897d33bff085">article</a>, I introduced the <em>smbd</em> python package, short for <em>‘symbolic multi-body dynamics’</em>, and how it approaches the problem. Short after that, I decided to breakup the package into smaller more focused sub-packages, in a layered architecture pattern, where each layer deals with a specific aspect of the problem. This code refactoring is intended to improve the design, structure, and implementation of the software, as well as improving the source-code maintainability and extensibility.</p><h3>URAEUS</h3><p><em>An open-source framework for the modeling, simulation and visualization of constrained multi-body systems.</em></p><p>As mentioned, the framework is structured as a “Layered Application”, containing three main layers of sub-packages. Each layer focuses on a specific aspect of the problem, and can be developed independently, with minimum dependency on the other packages.</p><p>These layers are as follows:</p><ol><li>Symbolic Environment Layer</li><li>Numerical Simulation Environments Layer</li><li>3D Visualization Environments Layer</li></ol><p>The high-level structure of the framework is represented below as a Model Diagram, that illustrates these layers and their corresponding sub-packages.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*htheRceubFZ8NHpX" /></figure><h3>The Workflow</h3><p>The workflow is greatly represented by the framework structure too, as we have three main parts we should tackle. The figure below shows a high-level activity diagram of a typical usage flow of the framework, where we have three swim-lanes representing the main three activity layers of the framework.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/661/0*k7GcPV9HcDQLGF3w" /></figure><p>We start at the symbolic environment lane, where we create our symbolic model, which is represented by the “<em>Symbolic Model Creation</em>” activity. This activity outputs two main objects.</p><ol><li>Symbolic Model: This is the symbolic model instance that contains the topological data of the multi-body system. This instance can be used directly to generate the numerical code through the code-generators provided, or can be saved as a binary .stpl file that can be used later.</li><li>Configuration File: This is a .json file that contains the numerical inputs needed to be provided by the user at the “Configuration Assignment” activity. This file is used to define how the system in configured in 3D space, which is used by the numerical simulation engine for the numerical simulation, and used by the visualization engines as well to construct a 3D visualization of the model.</li></ol><p>The “Symbolic Model” is then passed to the “<em>Numerical Code Generation</em>” activity, which creates the “Source Files” needed for the “<em>Numerical Model Creation</em>” activity along with the numerical configuration from the “<em>Configuration Assignment</em>” activity. This numerical model is then used by “<em>Numerical Simulations</em>” activity to run the desired simulations. For dynamic and kinematic simulations, the results can be stored as .csv files that can be used by the visualization engines to animate the constructed 3D model.</p><h3>Pendulum Example</h3><p>Now, let’s go back to our pendulum example. In our last <a href="https://medium.com/@kh.ghobashy/symbolic-multi-body-dynamics-in-python-1-system-abstraction-239da62780d7">article</a>, we discussed how would we abstract the kinematics and constraints of this simple pendulum. Now, we will use the uraeus.mbd framework to model, simulate and animate our simple pendulum, so follow along.</p><h3>Standalone Model</h3><p>The uraeus.smbd python package provides two main types of symbolic models to be constructed, standalone models, and template-based models.</p><p>Standalone models stands for symbolic models that are fully described in one topology graph, where all the bodies and connections are already defined in the model graph, and therefore, the model is fully independent and does not need any other topological information.</p><p>On the other hand, template-based models are not fully described in one topology, as they need to be assembled with other templates to form a complete assembled topology. For example, this is the case for creating a full vehicle assembly, where we model the vehicle subsystems as templates, then we assemble them together to form the desired vehicle assembly. The creation of template-based models’ database will be discussed in details in a future article.</p><p>For our case, the model will be created as a standalone model and project.</p><h3>Building the Symbolic Topology</h3><p>We start by importing the <em>standalone_topology</em> class from the systems module to create our symbolic model instance, and setting-up some needed directory variables.</p><pre># standard library imports<br>import os<br>	</pre><pre># uraeus imports<br>from uraeus.smbd.systems import standalone_topology, configuration<br>	</pre><pre># getting directory of current file and specifying the directory<br># where data will be saved</pre><pre>dir_name = os.path.dirname(__file__)</pre><pre>data_dir = os.path.join(dir_name, &#39;data&#39;)</pre><p>We then start constructing our system by adding the bodies, joints, actuators and/or forces. For our system, we have one body “<em>body</em>”, the pendulum, that is connected to the “<em>ground</em>” via a revolute joint “<em>a</em>”.</p><pre># ============================================================= #<br>#                       Symbolic Topology<br># ============================================================= #<br>	</pre><pre># Creating the symbolic topology as an instance of the<br># standalone_topology class</pre><pre>project_name = &#39;pendulum&#39;<br>sym_model = standalone_topology(project_name)<br>	</pre><pre># Adding Bodies<br># =============<br>sym_model.add_body(&#39;body&#39;)<br>	</pre><pre># Adding Joints<br># =============</pre><pre>sym_model.add_joint.revolute(&#39;a&#39;, &#39;ground&#39;, &#39;rbs_body&#39;)</pre><p>And that’s it; we have just created a symbolic topology that represents our simple pendulum mechanism. The topology graph of the system can be visualized by the method <em>sym_model.topology.draw_constraints_topology(). </em>Also we can check the number of constraint equations, generalized coordinates and the estimated degrees of freedom of the system. To finalize this step, we call the <em>assemble()</em> method to construct the governing equations symbolically then save the model.</p><pre># Assembling and Saving the model</pre><pre>sym_model.assemble()</pre><pre>sym_model.save(data_dir)</pre><p>We can check the system equations by accessing the appropriate topology attributes.</p><pre># Position level constraint equations.<br>sym_model.topology.pos_equations</pre><pre># System Jacobian of the position level constraint equations.</pre><pre>sym_model.topology.jac_equations</pre><h3>Building the Symbolic Configuration.</h3><p>The next step is to create a symbolic configuration of our symbolic model, but what is this symbolic configuration?</p><p>You may have noticed that we did not care explicitly about how our system is configured in space, we did not care about how our bodies or joints are located or oriented or how we can define these configuration parameters, all we cared about is only the topological connectivity. These configuration parameters already got generated automatically based on the used components. For example, the creation of a symbolic body “<em>body</em>” generates automatically the following symbolic parameters needed for the numerical simulation later on:</p><ul><li><strong><em>m_rbs_body</em></strong>: body mass.</li><li><strong><em>Jbar_rbs_body</em></strong>: inertia tensor.</li><li><strong><em>R_rbs_body</em></strong>: body reference point location vector.</li><li><strong><em>Rd_rbs_body</em></strong>: body translational velocity vector.</li><li><strong><em>P_rbs_body</em></strong>: body orientation quaternion.</li><li><strong><em>Pd_rbs_body</em></strong>: body orientation quaternion 1st time derivative.</li></ul><p>where the <strong><em>rbs_</em></strong> initial is short for “<em>rigid body single”</em>. If the body is mirrored, the system will create two bodies with the initials <strong><em>rbr_</em></strong> and <strong><em>rbl_</em></strong> for <strong>r</strong>ight and <strong>l</strong>eft respectively.</p><p>The same happens for edges’ components -joints, actuators and forces- where each component is responsible for creating its own configuration symbolic parameters.</p><p>These parameters are extracted from the symbolic topology to form the primary configuration layer that represents the needed user inputs for any given simulation. The benefit of the symbolic configuration is that we can construct our own layer of inputs that we desire to use in the numerical simulation and define the relations between these inputs and the primary parameters extracted from the topology components. This is best shown by example.</p><p>We start by creating our configuration instance, passing it a name and our symbolic model.</p><pre># Symbolic configuration name.<br>config_name = &#39;%s_cfg&#39;%project_name<br>	</pre><pre># Symbolic configuration instance.</pre><pre>sym_config = configuration(config_name, sym_model)</pre><p>Now we can check the primary configuration parameters extracted the from the symbolic topology by checking the <em>sym_config.config.input_nodes</em> variable, which returns a list of strings containing the inputs’ parameters names.</p><p>Now, we create our desired user inputs.</p><pre># Adding the desired set of UserInputs<br># ====================================<br>sym_config.add_point.UserInput(&#39;p1&#39;)<br>sym_config.add_point.UserInput(&#39;p2&#39;)</pre><pre>sym_config.add_vector.UserInput(&#39;v&#39;)</pre><p>After that, we set the relations between the primary configuration parameters and our custom configuration inputs.</p><pre># Defining Relations between original topology inputs<br># and our desired UserInputs.<br># ===================================================<br>	</pre><pre># Revolute Joint (a) location and orientation<br>sym_config.add_relation.Equal_to(&#39;pt1_jcs_a&#39;, (&#39;hps_p1&#39;,))</pre><pre>sym_config.add_relation.Equal_to(&#39;ax1_jcs_a&#39;, (&#39;vcs_v&#39;,))</pre><p>An optional and recommended step is to create symbolic geometries and assign these geometries to topology bodies to automatically evaluate the bodies configuration parameters stated earlier. Also this will be used to create 3D visualizations later.</p><pre># Creating Geometries<br># ===================<br>sym_config.add_scalar.UserInput(&#39;radius&#39;)<br>	</pre><pre>sym_config.add_geometry.Sphere_Geometry(&#39;body&#39;, (&#39;hps_p2&#39;, &#39;s_radius&#39;))</pre><pre>sym_config.assign_geometry_to_body(&#39;rbs_body&#39;, &#39;gms_body&#39;)</pre><p>The last step is to export the configuration data into a JSON file that can be used then by other numerical and visualization environments.</p><pre># Exporing the configuration as a JSON file</pre><pre>sym_config.export_JSON_file(data_dir)</pre><p>A version of the code we discussed can be found <a href="https://github.com/khaledghobashy/uraeus_mbd/blob/master/standalone_models/pendulum/symenv/sym_model.py">here</a> as well.</p><h3>Next Step</h3><p>In the next article we will discuss the following:</p><ul><li>How to manage the project structure where we save the generated files and codes.</li><li>The code-generation and numerical simulation of our simple pendulum model.</li><li>How to try this on your machine.</li></ul><p>I hope you find this useful is someway or another, and I will be really glad if you shared your insights and feedback with me.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d471e4f07049" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Symbolic Multi-Body Dynamics in Python | (1) System Abstraction]]></title>
            <link>https://medium.com/@kh.ghobashy/symbolic-multi-body-dynamics-in-python-1-system-abstraction-239da62780d7?source=rss-6e6ffe47a08c------2</link>
            <guid isPermaLink="false">https://medium.com/p/239da62780d7</guid>
            <category><![CDATA[multi-body-dynamics]]></category>
            <category><![CDATA[simulation]]></category>
            <category><![CDATA[modeling]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[symbolic-software]]></category>
            <dc:creator><![CDATA[Khaled Ghobashy]]></dc:creator>
            <pubDate>Fri, 25 Oct 2019 06:38:00 GMT</pubDate>
            <atom:updated>2019-10-25T06:38:00.511Z</atom:updated>
            <content:encoded><![CDATA[<p>In our <a href="https://medium.com/@kh.ghobashy/symbolic-multi-body-dynamics-in-python-an-introduction-897d33bff085">last article</a>, we discussed the essence of the field of modeling and simulation, and the growing need for such predictive technologies and the challenges it poses too. Then we narrowed our focus on the filed of Multi-Body Dynamics and its applications, and how the <a href="https://github.com/khaledghobashy/smbd"><strong>SMBD</strong></a> python package approaches the problem.</p><p>We ended our last article with a very relevant quote that states the fundamental essence of the function of modeling,</p><blockquote>“We have no idea about the ‘real’ nature of things … The function of modeling is to arrive at descriptions which are useful.”</blockquote><blockquote>- Richard Bandler and John Grinder, 1979</blockquote><p>In this article, we will discuss how do we abstract the <em>real nature</em> of multi-body systems into some <em>useful descriptions</em>, that help us in answering the questions that the problem poses on us.</p><p>The article is divided into the following sections:</p><ol><li>Rigid bodies in 3D space.</li><li>Multi-Body Systems (Pendulum).</li><li>Constraint Equations.</li><li>Degrees of Freedom.</li></ol><h4>1. Rigid bodies in 3D space.</h4><p>An <em>unconstrained</em> body in space has <em>6</em> degrees of freedom (DoF), <em>3 translational</em> DoF, where it can move freely along the <em>x, y</em> and <em>z</em> axes, as well as <em>3 rotational</em> DoF, where it can also rotate freely about the mentioned axes. So, in order to fully describe a given body in 3D space, we have to know where it is located and how it is oriented.</p><p>These information about the body is normally described using a set of <strong>6 generalized<em> </em>coordinates</strong><em> </em>that define the body configuration in space, <strong>3</strong> independent coordinates defining its <strong>location</strong><em> </em><strong>(x, y, z)</strong><em>,</em> and another <strong>3</strong> independent coordinates defining its <strong>orientation</strong><em> </em><strong>(α, β, γ)</strong>.</p><p>To be able to measure these generalized coordinates, we attach a <a href="https://en.wikipedia.org/wiki/Frame_of_reference">reference frame</a> to the body that is considered fixed to the body through out its motion in space. A reference frame is simply a <strong><em>set of three perpendicular vectors, of unit-length, intersecting at a point</em></strong>, which serves as the frame origin -normally chosen to be located at the body’s center of mass-. The figure below shows a simple cube body that illustrates the idea.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*13HEqANekIzAjeid" /></figure><p>Suppose we moved the cube and rotated it in the space; we can specify the body location by locating the reference frame origin, and we can specify the body orientation through the orientation of the vectors forming the reference frame. The animation below shows the same cube afterwards.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*0PivkAh-JANc1rlz" /></figure><p>Note: <em>Describing the orientation of the body reference frame in terms of only three independent parameters, e.g. (α, β, γ)</em>,<em> can be done in various ways in a process called “orientation parameterization”. This will be discussed later.</em></p><h4>2. Multi-Body Systems</h4><p>A multi-body system is simply a <em>finite number of material bodies connected in an arbitrary fashion by mechanical joints, that limit the relative motion between pairs of bodies </em>[1]. So, in order to fully describe the configuration of a given multi-body system, we have to know the configuration of each body in the system; for example, the configuration of a system of 10 bodies requires (6 x 10) 60 generalized coordinates to be fully specified.</p><p>But, due to the existence of these mechanical joints between the bodies, their motion -configuration- is <strong>not</strong> <strong>independent</strong> anymore, they became <strong>dependent</strong> on each other and they move in a certain way together, and therefore, the <em>configuration of the whole system can be determined via a smaller set of independent generalized coordinates, that can be used then to determine the dependent ones.</em></p><p>For example, we will consider the <a href="https://en.wikipedia.org/wiki/Pendulum">pendulum</a> as a very simple multi-body system.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*2BRLWV2Onoq4LefU" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*tnPo-cFGRj2RDxIs" /></figure><p>The pendulum is simply a multi body system that consists of <strong><em>two bodies</em></strong>, a <strong><em>pendulum</em></strong> and the <strong><em>ground</em></strong>, where the <em>pendulum is connected to the ground with a </em><strong><em>revolute</em></strong><em> joint</em> that allows the pendulum to <em>only</em> rotate about the joint axis -the green y-axis in the first picture-.</p><p>If we considered the pendulum as an unconstrained body in space, we know that we need 6 generalized coordinates, (x, y, z, α, β, γ), to fully describe its configuration (location and orientation). But in our case, the pendulum is connected to the ground through a <em>revolute joint</em>, which <em>constrains</em> the pendulum’s freedom-to-move to only 1 allowable rotation about the joint axis, and <em>prevents</em> all other displacements.</p><h4>3. Constraint Equations</h4><p>This constraint effect imposed by the revolute joint is abstracted mathematically as a set of <em>“</em><strong><em>algebraic constraint equations</em></strong><em>”</em> <em>that relates the generalized coordinates of the connected pair of bodies </em>-the pendulum and the ground in our case-, therefore, they become <strong>dependent</strong> on each other through these constraint equations.</p><p>Each constraint equation is responsible for the prevention of one relative displacement between the pair of bodies connected. The revolute joint provides <strong>5</strong> constraint equations to the system that constrain the pendulum to only rotate about the joint axis. We can think of these equations as they prevent the following <strong>5</strong> relative motions between the pendulum and the ground:</p><ul><li>Eq. 1 : Prevent relative translation along the x-axis at the joint location.</li><li>Eq. 2 : Prevent relative translation along the y-axis at the joint location.</li><li>Eq. 3 : Prevent relative translation along the z-axis at the joint location.</li><li>Eq. 4 : Prevent relative rotation about the x-axis.</li><li>Eq. 5 : Prevent relative rotation about the z-axis.</li></ul><p>And therefore, we are left with the allowed relative rotation about the y-axis, which represents the system <strong><em>degree of freedom</em></strong>.</p><h4>4. Degrees of Freedom</h4><p>Suppose we can measure the angle of rotation, <em>θ,</em> of the pendulum about the y-axis<em>.</em> This angle, θ, can be considered to be our <em>independent generalized coordinate</em>, which if we know its value, we can determine the full configuration (location and orientation) of the pendulum. We can also think of angle <em>θ</em> as our control input to the system, as we can easily control the system movement by putting a motor with the joint that can actuate the pendulum and control its angle of rotation about the joint axis.</p><p>We can define the degrees of freedom as<em> the minimum number of independent inputs required to control the system motion and to fully describe its configuration</em>.</p><p>We can think about a system’s degrees of freedom as “<em>How can it move or be controlled independently?</em>” or “<em>Can I move/rotate this body in that way without affecting the other connected bodies?</em>”</p><p>The degrees of freedom of a given system can be calculated traditionally using the <a href="https://en.wikipedia.org/wiki/Chebychev%E2%80%93Gr%C3%BCbler%E2%80%93Kutzbach_criterion"><strong>mobility criteria</strong></a>, <strong><em>d = 6(nb — 1) — nc</em></strong><em>.</em></p><p>Where, <strong><em>nb</em></strong> is the number of bodies in the system including the ground, <strong><em>nc</em></strong> is the number of constraint equations due to mechanical joints and/or prescribed motion actuators, and <strong><em>d</em> </strong>is the resulting degrees of freedom of the system.</p><h3>Next Step</h3><p>In the next article, we will see how can we model such a system in <strong>SMBD</strong> and will go through the adopted workflow of the modeling and simulation process.</p><h3>References</h3><p>[1] McPhee, J.J. Nonlinear Dyn (1996) 9: 73. <a href="https://doi.org/10.1007/BF01833294">https://doi.org/10.1007/BF01833294</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=239da62780d7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Symbolic Multi-Body Dynamics in Python — An Introduction.]]></title>
            <link>https://medium.com/@kh.ghobashy/symbolic-multi-body-dynamics-in-python-an-introduction-897d33bff085?source=rss-6e6ffe47a08c------2</link>
            <guid isPermaLink="false">https://medium.com/p/897d33bff085</guid>
            <category><![CDATA[multi-body-dynamics]]></category>
            <category><![CDATA[symbolic-software]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[modeling]]></category>
            <category><![CDATA[simulation]]></category>
            <dc:creator><![CDATA[Khaled Ghobashy]]></dc:creator>
            <pubDate>Sun, 06 Oct 2019 18:40:22 GMT</pubDate>
            <atom:updated>2019-10-06T18:40:22.334Z</atom:updated>
            <content:encoded><![CDATA[<h3>Symbolic Multi-Body Dynamics in Python — An Introduction.</h3><h3>INTRODUCTION</h3><p>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.</p><p>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-. <br>Eventually, these are just tools, and <em>“a tool is only as good as its user”</em>. 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.</p><h4>Increased Complexity Pitfall</h4><p>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.</p><blockquote>“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.”</blockquote><blockquote>- Sharp (1991)</blockquote><h4>Ease-of-Use Pitfall</h4><p>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.<br>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 <em>“garbage in, garbage out”</em><strong> </strong>pitfall, due to the lack of knowledge with the underlying formulations used in such tools.</p><p>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]</p><h3>The Link</h3><p>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 <a href="https://www.imeche.org/events/formula-student"><strong>Formula Student (FS)</strong></a> member for more than three years, and my main interest was in suspension system modeling and simulation.</p><p>The FSAE/FS competition is considered as an <strong><em>“educational engineering competition”</em></strong>, 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 <strong><em>“educational”</em></strong> some-times gets lost in the journey, and we are left only with the <strong><em>“competition”</em></strong> part. This results in an ill-balanced experience, where most of the students fall in the previously mentioned pitfalls, myself included.</p><p>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.</p><p>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 <em>“knowledge share”</em> adopted there by exposing it to the open-source community as well.</p><h3>SMBD | Symbolic Multi-Body Dynamics in Python</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*l1pOSonnuHLg_P2r" /><figcaption><em>“ Vehicle performing a lane-change maneuver — The full-vehicle model is created and simulated in SMBD and animated in blender”</em></figcaption></figure><p><a href="https://github.com/khaledghobashy/smbd"><strong>SMBD</strong></a> 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.</p><ol><li><em>What is Multi-Body Dynamics?</em></li><li><em>The Motive, The Audience and The Fields of Applications.</em></li><li><em>The “questions” to be answered.</em></li><li><em>How does the tool approaches the problem?</em></li><li><em>Current capabilities and features.</em></li></ol><h4>1- What is Multi-Body Dynamics?</h4><p>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]</p><h4>2- The Motive, The Audience and The Fields of Applications.</h4><p>Initially, the main targeted audience was the Formula Student community. The motive was to “<em>encourage deeper understanding of the modeling processes and the underlying theories used in other commercial software packages</em>”, 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. <br>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.</p><p>Fields of application include any domain that deals with the study of interconnected bodies, such as:</p><ul><li><em>Ground Vehicles’ Systems.</em></li><li><em>Construction Equipment.</em></li><li><em>Industrial Mechanisms.</em></li><li><em>Robotics.</em></li><li><em>Bio-mechanics.</em></li><li><em>.. etc.</em></li></ul><h4>3- The “Questions” to be answered.</h4><p>For a given multi-body system, the analyst may face different “<em>questions</em>” that he wish to answer. These questions mainly lie in <em>four</em> categories of analysis. These are:</p><ol><li><strong>Kinematic Analysis</strong>:<br><em>“How does the whole system move if we moved this particular body?”</em></li><li><strong>Inverse Dynamic Analysis</strong>:<em> <br>“What are the forces needed to achieve this motion we just did?”</em></li><li><strong>Equilibrium Analysis</strong>: <br><em>“How does the system look if we did nothing?”</em></li><li><strong>Dynamic Analysis</strong>: <br><em>“Now we gave it a force, how does it behave?”</em></li></ol><h4>4- How does the tool approaches the problem?</h4><p>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 <strong><em>symbolic computing</em></strong> and <strong><em>code-generation</em></strong>. The tool decomposes the problem into <em>three</em> major steps:</p><p><strong>1- Symbolic Topology Creation.</strong><br>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.<br>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.</p><p><strong>2- Numerical Environment Generation.</strong><br>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++.</p><p><strong>3- Numerical Simulation.</strong><br>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-.<br>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.</p><h4>5- Current capabilities and features.</h4><p><strong>1- Symbolic Model Creation</strong></p><ul><li>Creation of symbolic template-based and stand-alone multi-body systems using minimal API via python scripting.</li><li>Convenient and easy creation of complex multi-body assemblies.</li><li>Viewing the system’s symbolic equations in a natural mathematical format using Latex printing.</li></ul><p><strong>2- Numerical Simulation Environments<br></strong>The tool aims to provide a full encompassing simulation environments and not only code-generation. The tool currently provides:</p><ul><li>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 <a href="https://numpy.org/">NumPy</a> and <a href="https://www.scipy.org/">SciPy</a> libraries for numerical evaluation.</li><li>A numerical simulation environment in C++ that provides a solver that can be used to solve for Kinematically Driven Systems using <a href="http://eigen.tuxfamily.org/">Eigen</a> library as the linear algebra engine and selected modules from the <a href="https://www.boost.org/">Boost</a> library for other math functionalities. It also generates appropriate makefiles that automates the build process of model executable.</li></ul><p><strong>3- 3D Visualization<br></strong>A <a href="https://www.blender.org/">blender</a> add-on that can be easily added to blender’s GUI, to facilitate the visualization process of the simulated systems.</p><h3>Next Steps</h3><p>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.</p><p>And finally, I would like to share a very thought-provoking quote regarding the topic.</p><blockquote>“We have no idea about the ‘real’ nature of things … The function of modeling is to arrive at descriptions which are useful.”</blockquote><blockquote>- Richard Bandler and John Grinder, 1979</blockquote><p>Thank you for your time.</p><h3>References</h3><p>[1] Blundell, M., Harty, D., 2004, The Multibody Systems Approach to Vehicle Dynamics, Elsevier Butterworth-Heinemann, Oxford.</p><p>[2] Shabana, A.A., <em>Computational Dynamics</em>, Wiley, New York, 2010.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=897d33bff085" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>