This blog post will give the user some simple tips for speeding up the creation of a system model in Dymola. Often in a system model, several objects of the same type are required. Some of these objects might have identical parameterisation (hinges on a door: axis of rotation), others will have object-specific parameterisation.
The following screenshots will illustrate the shortcuts one can take to speed up replication of objects and parameterisation throughout system models by using menu shortcuts.
The multibody 4-bar linkage system model that will be built is shown in Figure 1. It is made up from:
- 4x Modelica.Mechanics.MultiBody.Parts.BodyShape
- 2x Modelica.Mechanics.MultiBody.Joints.Revolute
- 1x Modelica.Mechanics.MultiBody.Joints.RevolutePlanarLoopConstraint
- 1x Modelica.Mechanics.MultiBody.Joints.Prismatic
- 1x Modelica.MechanicslMultiBody.World
Figure 1: Fully assembled and parameterised system model of a 4-bar linkage.
The axis of rotation of the 3 revolutes will be identical (n={0,1,0}). The dimensions and centres of mass for each bodyShape will be identical for each bodyShape object. With this in mind we proceed to drag a World object into our model (required in all systems using multibody objects), followed by an instance of bodyShape (see Figure 2).
Figure 2: Parameterisation of the first instance of bodyShape.
We can parameterise this single instance of the bodyShape object for r, r_CM and m. We now have other 3 instances of bodyShape to create in our system model. We could repeat the process of dragging and dropping and parameterising other 3 instances of bodyShape but this would be inefficient and time consuming. By selecting bodyShape in our system model and using Ctrl+D we can duplicate the instance and its parameterisation 3 times to give us the remaining 3 bodyShape objects we require, complete with the correct parameterisation (see Figure 3).
Figure 3: Duplication of bodyShape via the Ctrl+D shortcut.
Next, we need to rearrange the duplicated objects to achieve the architecture layout shown in Figure 1. To move the objects we can select them and by re-clicking on them and keeping the left mouse button pressed, drag them to a suitable location in the diagram layer. Two bodyShape objects will require rotation and we can do this by selecting the two objects and pressing Ctrl+R which is an alternative to navigating the Edit menu to locate the same operator (see Figure 4). Horizontal and Vertical flipping can be achieved by pressing “H” or “V” on the keyboard whilst the object is in a selected state.
Figure 4: Rotation of bodyShape via the Ctrl+R shortcut.
Now we can add the multibody joints (see Figure 5):
- 2x Modelica.Mechanics.MultiBody.Joints.Revolute
- 1x Modelica.Mechanics.MultiBody.Joints.RevolutePlanarLoopConstraint
- 1x Modelica.Mechanics.MultiBody.Joints.Prismatic
…and by selecting all 3 revolutes and right clicking to select “Parameters”, set all three revolutes to have an axis of rotation about the y-axis ({0,1,0}) in one operation (see Figure 6).
Figure 5: Parameterisation of multi-selected objects.
Figure 6: Parameterisation of multi-selected objects – GUI.
Because there is only one prismatic instance, we will simply select the prismatic and set the axis of movement to be {1,0,0}. In the World object, n, the direction gravity will be acting in, should be set to {0,0,-1}
Figure 7: Resulting animation
Shortcuts can vastly speed up the creation of system models in Dymola. The shortcuts used in this example are:
- Ctrl+D
- Ctrl+R
- H
- V
Written by: Alessandro Picarelli – Chief Engineer
Please get in touch if you have any questions or have got a topic in mind that you would like us to write about. You can submit your questions / topics via: Tech Blog Questions / Topic Suggestion.