Simulation

Software for simulating simple planar multibody mechanical systems using Matter.js

Jul 31, 20243 min read
Software for simulating simple planar multibody mechanical systems using Matter.js
Paper (in Spanish): Arboleda, et al. Software para simulación de sistemas mecánicos multicuerpo planares simples utilizando Matter.js.

There are currently few software options for simulating two-dimensional multibody systems that allow simple simulations for teaching purposes. The available options tend to be expensive and complex to set up, which makes them far from ideal for educational tasks. With this in mind, this undergraduate thesis set out to create a web application for configuring and simulating planar multibody mechanical systems, to be used by students of the Dynamics of Mechanical Systems course. This document presents the theoretical framework, the methodology followed, and the results of the software's design and implementation. It concludes by revisiting the initial objectives and outlining future work.

simuplandes
Fig 1: Simuplandes

Video tutorials and demos

Below is a list of some video tutorials and demos of the software (in Spanish).

Simple pendulum tutorial Simple pendulum demo Double pendulum demo Four-bar linkage demo
Simple pendulum tutorial Simple pendulum demo Double pendulum demo Four-bar linkage demo
The simple pendulum tutorial shows how to set up and run a simple pendulum simulation. It covers the basic use of all of Simuplandes' tools. The simple pendulum demo shows a simulation of a simple pendulum. The double pendulum demo shows a simulation of a double pendulum. The four-bar linkage demo shows a simulation of a four-bar linkage.

The latest videos and demos are in the SimuplAndes playlist.

Open Simuplandes in the browser

Code repository

The Simuplandes GitHub repository is available at this link.

Results

This project produced a React application that runs in any modern browser and makes it possible to:

  1. Create and edit 3 types of bodies: rectangles, circles and complex polygons.
  2. Create and edit anchor points on the bodies.
  3. Define rotational constraints between two anchor points.
  4. Define forces at the anchor points.
  5. Run simulations based on the configuration defined in the previous steps.

However, due to limitations of the chosen physics engine (Matter.js), some simulations show errors or are unstable. The Conclusions section discusses these limitations.

Conclusions

The results represent significant progress toward the initial objectives. The solution uses modern languages and frameworks and can run in any browser (desktop or mobile). In addition, it allows creating bodies with different geometries, defining anchor points and rotational constraints between bodies, and applying point forces with fixed or variable directions. Although the user experience of the graphical interface can be improved, the current interface meets the minimum requirements for setting up and running simple simulations.

The simulation component, however, still has three shortcomings. First, the chosen physics engine (Matter.js) has no continuous collision detection (CCD) algorithm. As a result, tunneling between bodies occurs in some cases. Second, the constraints in the chosen physics engine are soft constraints rather than hard constraints. This leads to unexpected and undesirable behavior in the simulations. Finally, the chosen physics engine does not support prismatic constraints, so simulations with this type of constraint are not possible.

All three outstanding issues clearly stem from the chosen physics engine. Future work should therefore consider a different physics engine. Planck.js could be a viable replacement for the current engine: it supports hard rotational and prismatic constraints and has continuous collision detection.

SimulationMatter.jsPlanar multibody systemsPhysics engineReact.js