tut_17_modelica.pdf

Upload: muamera-hodzic

Post on 02-Jun-2018

219 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/10/2019 Tut_17_Modelica.pdf

    1/9

    Tutorial 17

    Getting Started with Modelica

    Objective

    This tutorial gives an introduction to SimulationX, explaining the first steps fromopening existing models and packages to modeling including resultinterpretation. For a better illustration of the process, a simple one mass oscillatorwill 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

    Graphical User Interface

    Figure 1 shows the Graphical User Interface of SimulationX including differentviews, 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 activatedvia the menu View.

    Figure 1: Customizable Graphical User Interface of SimulationX

    Opening Modelicafiles & packages

    Modeling withModelica StandardLibrary

    Editable Modelicacode createdautomatically

    Versatile analysispossibilities

    Diagram View

    Library

    Text View

    TaskPane

    ResultManage

    Model Explorer

    Result Window

    Output

  • 8/10/2019 Tut_17_Modelica.pdf

    2/9

    Page 2 of 9

    ITI Headquarters Schweriner Strae 1 01067 Dresden Germany T +49 (0) 351 26050 0 F +49 (0) 351 260 50 155 [email protected] For your local representative please visit www.simulationx.com/global

    ITI and SimulationX are registered trademarks of ITI GmbH Dresden. ITI GmbH, Dresden, Germany, 2013. All rights reserved. Modelica is a registered trademark of the Modelica Association. For further information please visi t www.modelica.org/documents Dymola is a registered trademark of Dynasim AB.

    Modelica Standard Library Examples

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

    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 ispossible to open Modelica examples in the Diagram View via double-click. Furthermore, you can decidewhether 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 andFixed of the Modelica Standard Library in the Diagram View. Therefore, just drag anddrop the elements fromMechanics.Translational.Componentsinto the Diagram View.

    2nd: OpenDiagram View

    1st: Right-click on

    the desired example

    3rd: DefineLibrary Barsettings

    http://www.modelica.org/documentshttp://www.modelica.org/documentshttp://www.modelica.org/documentshttp://www.modelica.org/documents
  • 8/10/2019 Tut_17_Modelica.pdf

    3/9

    Page 3 of 9

    ITI Headquarters Schweriner Strae 1 01067 Dresden Germany T +49 (0) 351.260 50 - 0 F +49 (0) 351.260 50 - 155 [email protected] For your local representative please visit www.simulationx.com/global

    ITI and SimulationX are registered trademarks of ITI GmbH Dresden. ITI GmbH, Dresden, Germany, 2013. All rights reserved. Modelica is a registered trademark of the Modelica Association. For further information please visi t www.modelica.org/documents Dymola is a registered trademark of Dynasim AB.

    Figure 3: Arrange the mechanical elements in the model view

    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 Parametersto 100 kg

    3. Switch to the tab Generaland change the name toMass

    ... as seen in figure 4.

    Figure 4: Definition of the parameters of the elementMass

    The next step is to set the properties and parameters of the spring damper. Therefore, the spring constantand 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 toSpringDamper

    The element fixed1is edited in the following way:1. Turn the element by clicking on the red arrow and moving the mouse

    with pressed mouse button2. Change the name to Restraint

    Before connecting the elements it is useful to label the pins via the menu View Pin Labels. Afterwards, theconnections can be drawn via left-click at the pin flange_bof the element Massand moving the mousewith pressed mouse button to flange_a of the element SpringDamper. SpringDamper and Restraint areconnected in the same way.

    Finally, a source to activate the mechanical system is needed. Choose the element ConstantForce fromMechanics.Translational.Sources, set its parameter Nominal Forceto 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 theProperty Window.

    Now the model of the one mass oscillator is finished and ready for simulation.

    Figure 6: General page of the TypeDesigner

    http://www.modelica.org/documentshttp://www.modelica.org/documentshttp://www.modelica.org/documentshttp://www.modelica.org/documents
  • 8/10/2019 Tut_17_Modelica.pdf

    4/9

    Page 4 of 9

    ITI Headquarters Schweriner Strae 1 01067 Dresden Germany T +49 (0) 351.260 50 - 0 F +49 (0) 351.260 50 - 155 [email protected] For your local representative please visit www.simulationx.com/global

    ITI and SimulationX are registered trademarks of ITI GmbH Dresden. ITI GmbH, Dresden, Germany, 2013. All rights reserved. Modelica is a registered trademark of the Modelica Association. For further information please visi t www.modelica.org/documents Dymola is a registered trademark of Dynasim AB.

    Visualization of the Modelica CodeA useful feature of SimulationX is the Text View option allowing you to edit the Modelica Code. Open theText View by right click on the tab of the Diagram View and select New Text View. A second view namedModel1*:2shows the Modelica code of the model. SimulationX provides the parallel display of both, theDiagram and the Text View, via clicking at one of the tabs and selecting New Vertical Tab Group. The mainsteps 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 infigure 9. After clicking at the Diagram View the clockwise rotation of the element Restrainis visible.

    http://www.modelica.org/documentshttp://www.modelica.org/documentshttp://www.modelica.org/documentshttp://www.modelica.org/documents
  • 8/10/2019 Tut_17_Modelica.pdf

    5/9

    Page 5 of 9

    ITI Headquarters Schweriner Strae 1 01067 Dresden Germany T +49 (0) 351.260 50 - 0 F +49 (0) 351.260 50 - 155 [email protected] For your local representative please visit www.simulationx.com/global

    ITI and SimulationX are registered trademarks of ITI GmbH Dresden. ITI GmbH, Dresden, Germany, 2013. All rights reserved. Modelica is a registered trademark of the Modelica Association. For further information please visi t www.modelica.org/documents Dymola is a registered trademark of Dynasim AB.

    Figure 9: Modify the Modelica code

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

    Figure 10: Saving options

    Original Modelica code:model Model 1

    Model i ca. Mechani cs. Transl at i onal . Components . Mass Mass( m=100) annot ati onModel i ca. Mechani cs. Transl at i onal . Components . Spr i ngDamper Spr i ngDamper (Model i ca. Mechani cs. Transl ati onal . Component s. Fi xed Restr ai nt annotat i on( Pl acement ( t r ansf ormati on(

    ori gi n={45, 10},ext ent ={{-10, - 10}, {10, 10}},r otat i on=- 270) ) ) ;

    Modified Modelica code:model Model 1

    Model i ca. Mechani cs. Transl at i onal . Components . Mass Mass( m=100) annot ati onModel i ca. Mechani cs. Transl at i onal . Components . Spr i ngDamper Spr i ngDamper (Model i ca. Mechani cs. Transl ati onal . Component s. Fi xed Restr ai nt annotat i on( Pl acement ( t r ansf ormati on(

    ori gi n={45, 10},ext ent ={{-10, - 10}, {10, 10}},r otat i on=0) ) ) ;

    http://www.modelica.org/documentshttp://www.modelica.org/documentshttp://www.modelica.org/documentshttp://www.modelica.org/documents
  • 8/10/2019 Tut_17_Modelica.pdf

    6/9

    Page 6 of 9

    ITI Headquarters Schweriner Strae 1 01067 Dresden Germany T +49 (0) 351.260 50 - 0 F +49 (0) 351.260 50 - 155 [email protected] For your local representative please visit www.simulationx.com/global

    ITI and SimulationX are registered trademarks of ITI GmbH Dresden. ITI GmbH, Dresden, Germany, 2013. All rights reserved. Modelica is a registered trademark of the Modelica Association. For further information please visi t www.modelica.org/documents Dymola is a registered trademark of Dynasim AB.

    Simulation and analysis

    The first step is to set the parameters for the transient simulation. Therefore, left-click the Property Dialogand set theStop Time tStopto 10 seconds. An alternative possibility to open the Property Dialogis viaSimulation Transient Settings.

    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 DiagramView and activate the protocol attribute of the absolute velocity vin the Model Explorer.Afterwards, right-click on the elementMassand select Results (transient) absolute velocity of componentvas shown in figure 12. A Result Window showing the velocity v of theMassas a function of time will bedisplayed.

    1st: OpenProperty Dialog

    2nd: SetSimulation time

    http://www.modelica.org/documentshttp://www.modelica.org/documentshttp://www.modelica.org/documentshttp://www.modelica.org/documents
  • 8/10/2019 Tut_17_Modelica.pdf

    7/9

    Page 7 of 9

    ITI Headquarters Schweriner Strae 1 01067 Dresden Germany T +49 (0) 351.260 50 - 0 F +49 (0) 351.260 50 - 155 [email protected] For your local representative please visit www.simulationx.com/global

    ITI and SimulationX are registered trademarks of ITI GmbH Dresden. ITI GmbH, Dresden, Germany, 2013. All rights reserved. Modelica is a registered trademark of the Modelica Association. For further information please visi t www.modelica.org/documents Dymola is a registered trademark of Dynasim AB.

    Figure 12: Select the results

    To add a second result activate the protocol attribute of the absolute position of the center of component sin the Model Explorer and open the Result Window via drag and drop of the activation button into theStructure View. To display both results in one common window just drag and drop the output quantity s Massinto the Result Window of v Massand adjust the window size.

    Via Extras Options Tab: Modelicayou have the additional possibility of setting the check on Switch onrecording of all result variables, but this option is only valid for models opened from the library bar.

    Figure 13: Ready for simulation including results velocity and position

    1st: Activate

    2nd: Select

    http://www.modelica.org/documentshttp://www.modelica.org/documentshttp://www.modelica.org/documentshttp://www.modelica.org/documents
  • 8/10/2019 Tut_17_Modelica.pdf

    8/9

    Page 8 of 9

    ITI Headquarters Schweriner Strae 1 01067 Dresden Germany T +49 (0) 351.260 50 - 0 F +49 (0) 351.260 50 - 155 [email protected] For your local representative please visit www.simulationx.com/global

    ITI and SimulationX are registered trademarks of ITI GmbH Dresden. ITI GmbH, Dresden, Germany, 2013. All rights reserved. Modelica is a registered trademark of the Modelica Association. For further information please visi t www.modelica.org/documents Dymola is a registered trademark of Dynasim AB.

    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, computedsteps 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 Massand 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 andset Y-AxisCommon Axisto true.For indicating the absolute velocity of the Massas a function of its position, click Options y(x)-Charttochange the axes. The described plots are shown in figure 15.

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

    http://www.modelica.org/documentshttp://www.modelica.org/documentshttp://www.modelica.org/documentshttp://www.modelica.org/documents
  • 8/10/2019 Tut_17_Modelica.pdf

    9/9

    Page 9 of 9

    ITI Headquarters Schweriner Strae 1 01067 Dresden Germany T +49 (0) 351.260 50 - 0 F +49 (0) 351.260 50 - 155 [email protected] For your local representative please visit www.simulationx.com/global

    ITI and SimulationX are registered trademarks of ITI GmbH Dresden. ITI GmbH, Dresden, Germany, 2013. All rights reserved. Modelica is a registered trademark of the Modelica Association. For further information please visi t www.modelica.org/documents Dymola is a registered trademark of Dynasim AB

    Via the menu ViewMeasure Baryou can measure all kinds of charts by mouse click.

    Figure 16: Measuring options

    Opening ModelsIn SimulationX you have two options for opening models. The most obvious method for opening a model isvia the menu File Open or the folder symbol. A second option is to drag the file from the Windowsexplorer 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 includingall result windows.Further customizing options concerning the opening actions and creation of models and types can be foundvia Extras Options Tab: Modelica.

    http://www.modelica.org/documentshttp://www.modelica.org/documentshttp://www.modelica.org/documentshttp://www.modelica.org/documents