Sunteți pe pagina 1din 9

Tutorial 17 Getting Started with Modelica

Objective
This tutorial gives an introduction to SimulationX, explaining the first steps from opening existing models and packages to modeling including result interpretation. For a better illustration of the process, a simple one mass oscillator will be built up using elements from the Modelica Standard Library. Workflow The following steps have to be carried out
Get to know the Graphical User Interface of SimulationX Open examples of the Modelica Standard Library Create a simple model of a one mass oscillator Run a simulation and analyze the results Open the generated model

Opening Modelica files & packages Modeling with Modelica Standard Library Editable Modelica code created automatically Versatile analysis possibilities

Graphical User Interface


Figure 1 shows the Graphical User Interface of SimulationX including different views, windows and managers. As its GUI is fully customizable you can decide where and when views and windows shall be visible. The views can be activated via the menu View.

Result Window

Diagram View

Text View Result Manage r

Library Bar

Model Explorer Output


Figure 1: Customizable Graphical User Interface of SimulationX

Task Pane

Page 2 of 9

Modelica Standard Library Examples


To open one of the examples of the Modelica Standard Library in the Diagram View right-click on the desired example and select Open Diagram View as seen in figure 2.

3rd: Define Library Bar settings

1st: Right-click on the desired example

2nd: Open Diagram View

Figure 2: Open an example of the Modelica Standard Library

With the help of the Library Bar settings you can define your specific standard actions. Therewith, it is possible to open Modelica examples in the Diagram View via double-click. Furthermore, you can decide whether name or comment of the model or even both shall be displayed in the library tree.

Creation of a simple model


For the creation of the model of a one mass oscillator you need to arrange the three elements Mass, SpringDamper and Fixed of the Modelica Standard Library in the Diagram View. Therefore, just drag and drop the elements from Mechanics.Translational.Components into the Diagram View.

Figure 3: Arrange the mechanical elements in the model view


ITI Headquarters Webergasse 1 01067 Dresden Germany T +49 (0) 351 26050 0 F +49 (0) 351 260 50 155 sales@simulationx.com SimulationX For your local representative please visit www.simulationx.com/global
ITI and SimulationX are registered trademarks of ITI GmbH Dresden. ITI GmbH, Dresden, Germany, 2012. All rights reserved. Modelica is a registered trademark of the Modelica Association. For further information please visit www.modelica.org/documents Dymola is a registered trademark of Dynasim AB.

Page 3 of 9 The definition of the properties and parameters of the sliding mass has to be carried out in three steps: 1. Open the property window via double-click on the element 2. Set the mass in the tab Parameters to 100 kg 3. Switch to the tab General and change the name to Mass ... as seen in figure 4.

Figure 4: Definition of the parameters of the element Mass

The next step is to set the properties and parameters of the spring damper. Therefore, the spring constant and the damping constant have to be defined including their specific quantities. 1. Open the property window of the element springDamper1 2. Set the value to 10000 N/m. Equivalent quantities can be chosen via the drop-down menu 3. Set the value of the damping constant to 100 Ns/m 4. Change the name of the element to SpringDamper The element fixed1 is edited in the following way: 1. Turn the element by clicking on the red arrow and moving the mouse with pressed mouse button 2. Change the name to Restraint Before connecting the elements it is useful to label the pins via the menu View Pin Labels. Afterwards, the connections can be drawn via left-click at the pin flange_b of the element Mass and moving the mouse with pressed mouse button to flange_a of the element SpringDamper. SpringDamper and Restraint are connected in the same way. Finally, a source to activate the mechanical system is needed. Choose the element ConstantForce from Mechanics.Translational.Sources, set its parameter Nominal Force to 10 kN and change its name to Force. To change the given quantity of the parameter use the drop-down menu at the right-hand side of the Property Window. Now the model of the one mass oscillator is finished and ready for simulation.

Figure 6: General page of the TypeDesigner

ITI Headquarters Webergasse 1 01067 Dresden Germany T +49 (0) 351 26050 0 F +49 (0) 351 260 50 155 sales@simulationx.com SimulationX For your local representative please visit www.simulationx.com/global
ITI and SimulationX are registered trademarks of ITI GmbH Dresden. ITI GmbH, Dresden, Germany, 2012. All rights reserved. Modelica is a registered trademark of the Modelica Association. For further information please visit www.modelica.org/documents Dymola is a registered trademark of Dynasim AB.

Page 4 of 9 Visualization of the Modelica Code A useful feature of SimulationX is the Text View option allowing you to edit the Modelica Code. Open the Text View by right click on the tab of the Diagram View and select New Text View. A second view named Model1*:2 shows the Modelica code of the model. SimulationX provides the parallel display of both, the Diagram and the Text View, via clicking at one of the tabs and selecting New Vertical Tab Group. The main steps are shown in figure 7, the result in figure 8.

Figure 7: Create the Text View of the model

Figure 8: Diagram View and Text View of the model

For a simple demonstration of the possibility of textual modeling we will rotate the element Restraint. Therefore you just have to change the rotation angle of the placement annotation to 0 degree as shown in figure 9. After clicking at the Diagram View the clockwise rotation of the element Restrain is visible.

ITI Headquarters Webergasse 1 01067 Dresden Germany T +49 (0) 351 26050 0 F +49 (0) 351 260 50 155 sales@simulationx.com SimulationX For your local representative please visit www.simulationx.com/global
ITI and SimulationX are registered trademarks of ITI GmbH Dresden. ITI GmbH, Dresden, Germany, 2012. All rights reserved. Modelica is a registered trademark of the Modelica Association. For further information please visit www.modelica.org/documents Dymola is a registered trademark of Dynasim AB.

Page 5 of 9

Original Modelica code:


model Model1 Modelica.Mechanics.Translational.Components.Mass Mass(m=100) annotation Modelica.Mechanics.Translational.Components.SpringDamper SpringDamper( Modelica.Mechanics.Translational.Components.Fixed Restraint annotation (Placement(transformation( origin={45,10}, extent={{-10,-10},{10,10}}, rotation=-270)));

Modified Modelica code:


model Model1 Modelica.Mechanics.Translational.Components.Mass Mass(m=100) annotation Modelica.Mechanics.Translational.Components.SpringDamper SpringDamper( Modelica.Mechanics.Translational.Components.Fixed Restraint annotation (Placement(transformation( origin={45,10}, extent={{-10,-10},{10,10}}, rotation=0)));

Figure 9: Modify the Modelica code

Saving the model When saving your model you can choose between the three file types SimulationX Model (*.ism), SimulationX Project (*.isx) and Modelica File (*.mo) via a drop-down menu. In general, models are saved including all data, comments and results, but you have several options for reducing the required disk space, e. g. by saving the model without results or compressing them (figure 10).

Figure 10: Saving options

ITI Headquarters Webergasse 1 01067 Dresden Germany T +49 (0) 351 26050 0 F +49 (0) 351 260 50 155 sales@simulationx.com SimulationX For your local representative please visit www.simulationx.com/global
ITI and SimulationX are registered trademarks of ITI GmbH Dresden. ITI GmbH, Dresden, Germany, 2012. All rights reserved. Modelica is a registered trademark of the Modelica Association. For further information please visit www.modelica.org/documents Dymola is a registered trademark of Dynasim AB.

Page 6 of 9

Simulation and analysis


The first step is to set the parameters for the transient simulation. Therefore, left-click the Property Dialog and set the Stop Time tStop to 10 seconds. An alternative possibility to open the Property Dialog is via Simulation Transient Settings.

1st: Open Property Dialog

2nd: Set Simulation time

Figure 11: Set the simulation parameters

In order to save space and speed up the simulation, results are not logged automatically. Instead you choose them explicitly before starting the simulation. Therefore select the element Mass in the Diagram View and activate the protocol attribute of the absolute velocity v in the Model Explorer. Afterwards, right-click on the element Mass and select Results (transient) absolute velocity of component v as shown in figure 12. A Result Window showing the velocity v of the Mass as a function of time will be displayed.

ITI Headquarters Webergasse 1 01067 Dresden Germany T +49 (0) 351 26050 0 F +49 (0) 351 260 50 155 sales@simulationx.com SimulationX For your local representative please visit www.simulationx.com/global
ITI and SimulationX are registered trademarks of ITI GmbH Dresden. ITI GmbH, Dresden, Germany, 2012. All rights reserved. Modelica is a registered trademark of the Modelica Association. For further information please visit www.modelica.org/documents Dymola is a registered trademark of Dynasim AB.

Page 7 of 9

2nd: Select

1st: Activate

Figure 12: Select the results

To add a second result activate the protocol attribute of the absolute position of the center of component s in the Model Explorer and open the Result Window via drag and drop of the activation button into the Structure View. To display both results in one common window just drag and drop the output quantity s Mass into the Result Window of v Mass and adjust the window size. Via Extras Options Tab: Modelica you have the additional possibility of setting the check on Switch on recording of all result variables, but this option is only valid for models opened from the library bar.

ITI Headquarters Webergasse 1 01067 Dresden Germany T +49 (0) 351 26050 0 F +49 (0) 351 260 50 155 sales@simulationx.com SimulationX For your local representative please visit www.simulationx.com/global
ITI and SimulationX are registered trademarks of ITI GmbH Dresden. ITI GmbH, Dresden, Germany, 2012. All rights reserved. Modelica is a registered trademark of the Modelica Association. For further information please visit www.modelica.org/documents Dymola is a registered trademark of Dynasim AB.

Page 8 of 9

Figure 13: Ready for simulation including results velocity and position

Now the model can be simulated. Start the simulation using either the start icon in the toolbar, pressing F5 or use the menu Simulation Start. After having finished the simulation run, detailed information concerning the computation time, computed steps etc. are displayed in the output window (figure 14).

Figure 14: Simulation finished successfully

Analysis To display both output quantities in one chart select s Mass and drag it into the chart of the velocity v Mass. To display both characteristics on a common axis, left-click View Property Bar, select the Panel and set Y-Axis Common Axis to true. For indicating the absolute velocity of the Mass as a function of its position, click Options y(x)Chart to change the axes. The described plots are shown in figure 15.

Figure 15: Different plotting options y(t) and y(x)

ITI Headquarters Webergasse 1 01067 Dresden Germany T +49 (0) 351 26050 0 F +49 (0) 351 260 50 155 sales@simulationx.com SimulationX For your local representative please visit www.simulationx.com/global
ITI and SimulationX are registered trademarks of ITI GmbH Dresden. ITI GmbH, Dresden, Germany, 2012. All rights reserved. Modelica is a registered trademark of the Modelica Association. For further information please visit www.modelica.org/documents Dymola is a registered trademark of Dynasim AB.

Page 9 of 9

Via the menu View Measure Bar you can measure all kinds of charts by mouse click.

Figure 16: Measuring options

Opening Models
In SimulationX you have two options for opening models. The most obvious method for opening a model is via the menu File Open or the folder symbol. A second option is to drag the file from the Windows explorer into the SimulationX Diagram View. One fact both options have in common is that the model is opened in the same view it was saved including all result windows. Further customizing options concerning the opening actions and creation of models and types can be found via Extras Options Tab: Modelica.

ITI Headquarters Webergasse 1 01067 Dresden Germany T +49 (0) 351 26050 0 F +49 (0) 351 260 50 155 sales@simulationx.com SimulationX For your local representative please visit www.simulationx.com/global
ITI and SimulationX are registered trademarks of ITI GmbH Dresden. ITI GmbH, Dresden, Germany, 2012. All rights reserved. Modelica is a registered trademark of the Modelica Association. For further information please visit www.modelica.org/documents Dymola is a registered trademark of Dynasim AB.

S-ar putea să vă placă și