# Multibody Modeling

System Modeler comes with a multibody library that can be used for 3D mechanical modeling.

 MODELS USED IN THIS TUTORIAL PlanarLoop | Pendulum | FullRobot

## The MultiBody Library

Modelica.Mechanics.MultiBody is a Modelica library for 3D mechanical modeling. Working with 3D models can be complicated, since all parts need to be connected in space and initial values need to be correct in order for the system to start. System Modeler contains visualization for models created with the MultiBody library to aid the user in analyzing the movement in a convenient way. Following are some important things to consider when working with the MultiBody library. An introduction to the library as well as information about its components can be found by accessing the embedded documentation of the MultiBody package and its classes. The following figure shows the PlanarLoop model of a planar loop built with the MultiBody library.

Example of a planar loop.

### Initial Values

When the model is translated (built), appropriate states are selected. It is important to get the system to initialize these states properly to get a physically meaningful simulation. This example uses fixed initialization of the angle phi and angular velocity w in the revolute3 component. The initial values of these variables are shown in the Variables tab in Simulation Center.

Selected states for the model in the previous screen shot.

As seen in the preceding screenshot, the angle of the joint revolute3 will start with the speed 0.0 rad/s and at the angle 50 degrees. These values can also be changed directly in the model in the General tab in Model Center.

### Angle and Position of Objects

It is very important to get a physically correct model, otherwise the system will likely fail to start a simulation. Try to use simple directions, e.g. r={1,0,0}, r={0,-1,0} for components like BodyCylinder, BodyBox, etc. If another direction is needed, change phi in a joint or use the FixedRotation and FixedTranslation components available in MultiBody.Parts.

### Animations

Some of the MultiBody components contain animation information. These are the Body, BodyBox, BodyCylinder and BodyShape components in MultiBody.Parts. There are also visualizers that show properties like velocity, acceleration, etc. in MultiBody.Visualizers.

Animation of PlanarLoop, showing the motion of the three BodyCylinder parts.

As indicated by their respective names, the BodyBox is box shaped and the BodyCylinder is cylinder shaped. If more variants of animated shapes are needed, e.g. sphere, cone, gearwheel, etc., the BodyShape can be used, setting the parameter shapeType to the desired shape. If only a pure animation is needed without physical properties, the Shape object can be used.

The following figure shows an example of a pendulum with a sphere at the end, where the BodyShape component has been used to animate the sphere. The diagram of the Pendulum model as well as the corresponding animation can be seen in the figures.

The Pendulum model with a sphere shape at the end.

Animation of the Pendulum model with a sphere shape at the end.

`modelica://<Modelica-name>/<relative-file-path>`