02 Mechanical Modelling
02 Mechanical Modelling
OpenModelica
Department of Mechanical and Electrical Engineering
Massey University
E: [email protected]
O: AV 1.18, Albany Village
1
Introduction
In this presentation, I will describe:
2
Getting Started
Create a new directory named "openmodelica_projects" in
C:\Users\%USER%\Documents\ .
3
Open the Start menu, type "OpenModelica Connection Editor", and select the app.
4
Afterwards, something similar to the following will be displayed:
Figure: OMEdit.
5
Model a translational system in OpenModelica
Here, we will use OpenModelica to model the following translational system:
Assume , , , , and
.
6
The differential equations that describe this system are:
Assume , , , .
Note: , , .
7
Solving for and , we get:
8
translation.mo
These equations can be implemented in OpenModelica as:
9
Figure: Plot of 's value as a function of time.
10
example_01.mo
Either:
11
Afterwards, something similar to the following will be displayed:
12
Afterwards, something similar to the following will be displayed:
Figure: OMEdit. Here, the example_01 model is shown. The white area is where blocks
can be dragged onto.
13
Either:
14
Afterwards, something similar to the following will be displayed:
Browse to C:\Users\%USER%\openmodelica_projects\mechanical_modelling .
15
Afterwards, something similar to the following will be displayed:
Note: To make it easier to browse the Modelica library, left click on OMEdit's left most
panel and drag its handle to the right.
Figure: OMEdit.
Figure: OMEdit.
18
Expand the "Modelica" and "Mechanics" libraries.
Figure: OMEdit.
The Translational library contains blocks that can be used to model translational
systems, e.g. "Spring", "Mass", "Damper", and "Force".
19
In the Libraries Browser, search for an "Fixed" block. Expand the Modelica , Mechanics ,
Translational , and Components libraries. Drag the block onto the model as illustrated:
Figure: OMEdit.
20
In Libraries Browser, search for an "Damper" block. Expand the Modelica , Mechanics ,
Translational , and Components libraries. Drag the block onto the model as illustrated:
Figure: OMEdit.
21
In Libraries Browser, search for an "Mass" block. Expand the Modelica , Mechanics ,
Translational , and Components libraries. Drag the block onto the model as illustrated:
Figure: OMEdit.
22
In Libraries Browser, search for an "Spring" block. Expand the Modelica , Mechanics ,
Translational , and Components libraries. Drag the block onto the model as illustrated:
Figure: OMEdit.
23
In Libraries Browser, search for an "Mass" block. Expand the Modelica , Mechanics ,
Translational , and Components libraries. Drag the block onto the model as illustrated:
Figure: OMEdit.
24
In Libraries Browser, search for an "PositionSensor" block. Expand the Modelica ,
Mechanics , Translational , and Sensors libraries. Drag the block onto the model as
illustrated:
Figure: OMEdit.
Figure: OMEdit.
26
In Libraries Browser, search for an "Step" block. Expand the Modelica , Blocks , and
Sources libraries. Drag the block onto the model as illustrated:
Figure: OMEdit.
27
In Libraries Browser, search for an "RealOutput" block. Expand the Modelica , Blocks ,
and Interfaces libraries. Drag the block onto the model as illustrated:
Figure: OMEdit.
28
Connect the blocks as illustrated:
Figure: OMEdit.
Change damper 's "d" parameter's value to "20"; change mass 's "m" parameter's value
to "10"; change spring 's "c" parameter's value to 30; change mass1 's "m" parameter's
value to "10"; and change step 's "height" parameter's value to "1000".
29
Either:
30
Afterwards, something similar to the following will be displayed:
31
Either:
32
Afterwards, something similar to the following will be displayed:
33
Afterwards, something similar to the following will be displayed:
34
Afterwards, something similar to the following will be displayed:
Figure: OMEdit.
35
Afterwards, something similar to the following will be displayed:
Figure: OMEdit.
36
To return to the Modeling view, left click on the "Modeling" tab.
To simulate the system with different parameters, e.g. a longer simulation stop time,
either:
37
Model a rotational system in OpenModelica
Here, we will use OpenModelica to model the following rotational system:
Assume , , , ,
, and .
38
The differential equations that describe this system are:
Assume , , , .
Note: , , .
39
Solving for and , we get:
40
rotational.mo
These equations can be implemented in OpenModelica as:
41
Figure: Plot of 's value as a function of time.
42
example_02.mo
Either:
43
Afterwards, something similar to the following will be displayed:
44
Afterwards, something similar to the following will be displayed:
Figure: OMEdit. Here, the example_02 model is shown. The white area is where blocks
can be dragged onto.
45
Either:
46
Afterwards, something similar to the following will be displayed:
Browse to C:\Users\%USER%\openmodelica_projects\mechanical_modelling .
47
Afterwards, something similar to the following will be displayed:
Note: To make it easier to browse the Modelica library, left click on OMEdit's left most
panel and drag its handle to the right.
Figure: OMEdit.
Figure: OMEdit.
50
Expand the "Modelica" and "Mechanical" libraries.
Figure: OMEdit.
The Rotational library contains blocks that can be used to model rotational systems,
e.g. "Spring", "Mass", "Damper", and "Torque".
51
In the Libraries Browser, search for an "Fixed" block. Expand the Modelica , Mechanics ,
Rotational , and Components libraries. Drag the block onto the model as illustrated:
Figure: OMEdit.
52
In Libraries Browser, search for an "Damper" block. Expand the Modelica , Mechanics ,
Rotational , and Components libraries. Drag the block onto the model as illustrated:
Figure: OMEdit.
53
In Libraries Browser, search for an "Inertia" block. Expand the Modelica , Mechanics ,
Rotational , and Components libraries. Drag the block onto the model as illustrated:
Figure: OMEdit.
54
In Libraries Browser, search for an "Spring" block. Expand the Modelica , Mechanics ,
Rotational , and Components libraries. Drag the block onto the model as illustrated:
Figure: OMEdit.
55
In Libraries Browser, search for an "Inertia" block. Expand the Modelica , Mechanics ,
Rotational , and Components libraries. Drag the block onto the model as illustrated:
Figure: OMEdit.
56
In Libraries Browser, search for an "Damper" block. Expand the Modelica , Mechanics ,
Rotational , and Components libraries. Drag the block onto the model as illustrated:
Figure: OMEdit.
57
In Libraries Browser, search for an "AngleSensor" block. Expand the Modelica ,
Mechanics , Rotational , and Sensors libraries. Drag the block onto the model as
illustrated:
Figure: OMEdit.
Figure: OMEdit.
59
In Libraries Browser, search for an "Step" block. Expand the Modelica , Blocks , and
Sources libraries. Drag the block onto the model as illustrated:
Figure: OMEdit.
60
In Libraries Browser, search for an "RealOutput" block. Expand the Modelica , Blocks ,
and Interfaces libraries. Drag the block onto the model as illustrated:
Figure: OMEdit.
61
Connect the blocks as illustrated:
Figure: OMEdit.
Change damper 's "d" parameter's value to "20"; change inertia 's "j" parameter's
value to "10"; change spring 's "c" parameter's value to 30; change inertia1 's "j"
parameter's value to "10"; change damper1 's "d" parameter's value "20"; and change
step 's "height" parameter's value to "1000".
62
Either:
63
Afterwards, something similar to the following will be displayed:
64
Either:
65
Afterwards, something similar to the following will be displayed:
66
Afterwards, something similar to the following will be displayed:
67
Afterwards, something similar to the following will be displayed:
Figure: OMEdit.
68
Afterwards, something similar to the following will be displayed:
Figure: OMEdit.
69
To return to the Modeling view, left click on the "Modeling" tab.
To simulate the system with different parameters, e.g. a longer simulation stop time,
either:
70
Conclusion
In this presentation, I have described:
71
References
1. https://www.openmodelica.org/
72