0% found this document useful (0 votes)
16 views72 pages

02 Mechanical Modelling

Uploaded by

穆林
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views72 pages

02 Mechanical Modelling

Uploaded by

穆林
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 72

How to model mechanical systems with

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:

How to model translational and rotational systems with OpenModelica.

2
Getting Started
Create a new directory named "openmodelica_projects" in
C:\Users\%USER%\Documents\ .

Note: Change %USER% to your username.

Create a new directory in C:\Users\%USER%\Documents\openmodelica_projects named


"mechanical_modelling".

3
Open the Start menu, type "OpenModelica Connection Editor", and select the app.

This will start OpenModelica's Connect Editor (OMEdit).

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:

Figure: A translational mechanical 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:

Figure: Block diagram.

9
Figure: Plot of 's value as a function of time.

10
example_01.mo
Either:

1. Left click on the "New Modelica Class" button; or,


2. Select "File > New Modelica Class".

11
Afterwards, something similar to the following will be displayed:

Figure: OMEdit - Create New Modelica Class window.

Type "example_01" into the "Name" line edit's input.

Left click on the "OK" button.

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:

1. Left click on the "Save" button; or,


2. Select "File > Save".

14
Afterwards, something similar to the following will be displayed:

Figure: Save model window.

Browse to C:\Users\%USER%\openmodelica_projects\mechanical_modelling .

Left click on the "Save" button.

15
Afterwards, something similar to the following will be displayed:

Figure: OMEdit. Here the "Modeling" view is shown.

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.

Right click on the model's workspace. Select "Parameters".


16
Afterwards, something similar to the following will be displayed:

Figure: OMEdit.

Type "-200" into the "Left" line edit's input.

Type "200" into the "Right" line edit's input.

Left click on the "OK" button.


17
Afterwards, something similar to the following will be displayed:

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.

Name the block "fixed".

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.

Name the block "damper".

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.

Name the block "mass".

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.

Name the block "spring".

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.

Name the block "mass1".

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.

Name the blocks "positionSensor" and "positionSensor1".


25
In Libraries Browser, search for an "Force" block. Expand the Modelica , Mechanics ,
Translational , and Sources libraries. Drag the block onto the model as illustrated:

Figure: OMEdit.

Name the block "force".

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.

Name the block "step".

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.

Name the blocks "y" and "y1".

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:

1. Left click on the "Check Model" button; or,


2. Select "Simulate > Check Model".

30
Afterwards, something similar to the following will be displayed:

Figure: OMEdit - Check Model window.

Left click on the "OK" button.

31
Either:

1. Left click on the "Simulation Setup" button; or,


2. Select "Simulation > Setup".

32
Afterwards, something similar to the following will be displayed:

Figure: OMEdit - Simulation Setup window.

Type "10" into the "Stop Time" line edit's input.

Left click on the "OK" button.

33
Afterwards, something similar to the following will be displayed:

Figure: OMEdit - Simulation Output window.

34
Afterwards, something similar to the following will be displayed:

Figure: OMEdit.

Expand the "step" menu. Check the "y" checkbox.

Check the "y" checkbox.

35
Afterwards, something similar to the following will be displayed:

Figure: OMEdit.

Here, 's value is plotted as a function of time.

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:

1. Left click on the "Simulation Setup" button; or,


2. Select "Simulation > Setup".

37
Model a rotational system in OpenModelica
Here, we will use OpenModelica to model the following rotational system:

Figure: A rotational mechanical 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:

Figure: Block diagram.

41
Figure: Plot of 's value as a function of time.

42
example_02.mo
Either:

1. Left click on the "New Modelica Class" button; or,


2. Select "File > New Modelica Class".

43
Afterwards, something similar to the following will be displayed:

Figure: OMEdit - Create New Modelica Class window.

Type "example_02" into the "Name" line edit's input.

Left click on the "OK" button.

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:

1. Left click on the "Save" button; or,


2. Select "File > Save".

46
Afterwards, something similar to the following will be displayed:

Figure: Save model window.

Browse to C:\Users\%USER%\openmodelica_projects\mechanical_modelling .

Left click on the "Save" button.

47
Afterwards, something similar to the following will be displayed:

Figure: OMEdit. Here the "Modeling" view is shown.

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.

Right click on the model's workspace. Select "Parameters".


48
Afterwards, something similar to the following will be displayed:

Figure: OMEdit.

Type "-200" into the "Left" line edit's input.

Type "200" into the "Right" line edit's input.

Left click on the "OK" button.


49
Afterwards, something similar to the following will be displayed:

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.

Name the block "fixed".

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.

Name the block "damper".

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.

Name the block "inertia".

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.

Name the block "spring".

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.

Name the block "inertia1".

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.

Name the block "damper1".

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.

Name the blocks "angleSensor" and "angleSensor1".


58
In Libraries Browser, search for an "Torque" block. Expand the Modelica , Mechanics ,
Rotational , and Sources libraries. Drag the block onto the model as illustrated:

Figure: OMEdit.

Name the block "torque".

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.

Name the block "step".

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.

Name the blocks "y" and "y1".

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:

1. Left click on the "Check Model" button; or,


2. Select "Simulate > Check Model".

63
Afterwards, something similar to the following will be displayed:

Figure: OMEdit - Check Model window.

Left click on the "OK" button.

64
Either:

1. Left click on the "Simulation Setup" button; or,


2. Select "Simulation > Setup".

65
Afterwards, something similar to the following will be displayed:

Figure: OMEdit - Simulation Setup window.

Type "10" into the "Stop Time" line edit's input.

Left click on the "OK" button.

66
Afterwards, something similar to the following will be displayed:

Figure: OMEdit - Simulation Output window.

67
Afterwards, something similar to the following will be displayed:

Figure: OMEdit.

Expand the "step" menu. Check the "y" checkbox.

Check the "y" checkbox.

68
Afterwards, something similar to the following will be displayed:

Figure: OMEdit.

Here, 's value is plotted as a function of time.

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:

1. Left click on the "Simulation Setup" button; or,


2. Select "Simulation > Setup".

70
Conclusion
In this presentation, I have described:

How to model translational and rotational systems with OpenModelica.

71
References
1. https://www.openmodelica.org/

72

You might also like