Home

Getting started with Dymola

image

Contents

1. Another convenient way is to use the component browser Put the cursor on top of the wanted component in the browser and right click to get the context menu Select Show Component as shown in the figure below In this case also care must be taken not to select any axes of the module mechanics The component browser has been enlarged in the figure to illustrate this Since Show Component is the first menu option double clicking will yield the same result Please recall that double clicking on a component in the edit window pops up the parameter dialog compare the two menus in the figure above and below 12 Displaying the components of axis 1 The robot drive train in Axis 1 axiz1 c Component Browser Components Modelica Mechanics MultiBody Examples E mechanic a gt anise B ais Bl aisd B ass Bl ais world r2 r3 d 15 5 E bl Hbl a b2 b3 b 65 bE load 05 bPlanning axis5 A axiscontrolBuso J mechanics axis5 axisControlBuss J axig4 sxisControlBus4 J axis3 mxisControlBus3 J controlBus axis zi isControlBus2 p Whatever method is used the result will be the following figure in the edit window sngjodua2sixe controller angleSenzor angle Speed acceleration flange The drive train includes a controller A data bus is used to send measurements and reference sig
2. Component Browser mx Components Modelica Mechanics i MilgLibrary2 Modelica Icons Library2 Modeling V Simulation To get documentation on Modelica Mechanics as previously demonstrated place the cursor on Mechanics right click and select Info Besides using the package browser of the Dymola window it is also possible to open a li brary window that also contains a browser It can be done in two ways If the library window should contain the Mechanics package select Mechanics in the package browser and right click to get a menu Select Open Library Window If the window should contain the top package in the browser Modelica in this case use the toolbar to select Window New Library Window Using the latter selecting Modelica in the Package browser in the upper part of the window and adapting the window will display the following GETTING STARTED WITH DYMOLA 37 A library window dis playing the Modelica Standard Library 38 Library Window DEAR Packages fl iiiodelica Reference BH Modelica 1 User s Guide amp fg Blocks amp Gg SteteGraph amp Electrical amp SS Magnetic amp fea Mechanics 2 amp Fluid amp Media amp Thermal amp Math amp utiities amp E Constants gil Icons H stunits Unnamed UsersGuide Blocks Statearaph Electrical Utilities Constants A Library window includes a package browser where
3. MotarDriveTest DriveLib MotorDrive Test File mL GO 86 M m wu b TL old 44 4I Db Time o Variable Browser Plot Animation Comman Simulation variables Values MotorDriveTest 1 IMatorDriveTest 2 gearbox phiload motor load positionerrar controller 5 sr Om wa step The parameters r and m can be set interactively between simulation runs but not the parameter load J because it is no longer a free parameter an expression is now binding it to r and m 1 4 9 Documenting the simulation The command window can be used to document the simulation Text also headers images and links can be inserted and edited using the tools that are available in the toolbar in the top of the command window Plot results can also be automatically be inserted in the command log by entering the following in the command input line at the bottom of the command window Advanced ScriptingWindow IncludePlot true Followed by Enter in the command input line see figure below hal Advanced ScriptingWindow IncludePlot true IH Madeling y simulation This is by the way a typical example of setting a flag using flags is not unusual in Dymola Now the content in the command log pane can be edited to document the simulation in a good way Commands given and output results will be automatically be included including plots An example of documenting better values of
4. selecting Expand Show entire text However we refrain from showing it in this document Below the Modelica text as a result of first selecting select Expand Show components and connect and then the annotation for Motor has been individually expanded by clicking on a corresponding in the margin which means that now a is shown indicating the possibility to compress that annotation individually MotorDrive DriveLib MotorDrive Modelica Text BEES Ej rie Edi Commands Window Help B X 5 co A P m er SHAS NM VNOOVABY amp Z Me gt 2S BES o Package Browser Bx model MotorDrive Boned MEE 6 Modelica Mechanics Rotational C ts Ideal box ratio 3 wavenumber T odelica Mechanics Rotational Components IdealGear gearbox ratio i Circular WaveNumber s a i it Modelica Mechanics Rotational Sensors AngleSensor phiload a AmplitudeLevelDifference L Lp LevelDiff Motor motor a dig SAES Modelica Mechanics Rotational Components Inertia load J 10 DampingCoefficient E ws r LogarithmicDecrement Modelica Blocks Math Feedback positionerror gt AttenuationCoefficient 8 r PhaseCoefficient Modelica Blocks Continuous PID controller D x fixed true PropagationCoefficient a Damping d a Mass v parameter Modelica SIunits Radius r 0 5 Radius of load amp mJ parameter Modelica SIunits Mass m 80 Mass of load Bug equation Component Browser Bx
5. uA end Pendulum The in the margin to the left of the text and the icon almost at the end of the text indicates the presence of graphical information or annotations It may be displayed This can be done in two ways Either click on the or on the icon or right click to get the context menu and then select Expand gt Show entire text Either way it is revealed that the annotation is an annotation documenting which version of the Modelica standard library was used Dymola uses this information to check if compatible versions of libraries are used and to support automatic upgrading of models to new versions of libraries A model developer can provide conversion scripts that specify how models shall be upgraded automatically to new versions of a library Please note that if changes should be made afterwards the command Edit gt Variables can be used to select the variable that should be edited Another way of inserting pre defined physical quantities is to recognize that these are types Types can be inserted in the code by right clicking to pop the context menu and then selecting Insert Type The menu that pops enables searching by typing in names The advantage is that all types in all open packages are searched It will be easy to find a known type even if it located in another package However to also get help from the Declare variable menu as above the user has to e Insert the type on an empty line e Enter a space a
6. This layer can be used to display more extensive information about packages and components Please see chapter Developing a model section Basic Model editing sub section Documentation for more information This type of documentation can also be exported to HTML files etc Books etc Manuals are available for Dymola and a number of libraries used as well as for the Modelica language GETTING STARTED WITH DYMOLA 1 82 2 Index A animation 17 animation window 16 moving view 17 pan view 17 roll view 17 rotate view 17 scroll view 17 set rotation center 17 tilt view 17 zooming 17 B bound parameter 64 browser component amp C class documentation 51 extend 62 component browser amp library 42 reference 67 context menu 8 creating a model 44 D DC motor 33 declarations 21 der operator 20 diagram layer 17 documentation editor See editor documentation manuals 8 of class 51 of model 5 of simulation 69 E edit documentation of class 52 documentation of simulation 69 83 editor documentation of class 52 documentation of simulation 69 examples DC motor 33 Furuta pendulum 72 pendulum 20 experiment setup 23 extend 62 F fixed attribute of start value 32 flag 69 Furuta pendulum 72 H highlight syntax 22 info button 11 L library 42 manhattanize 50 model documentation 5 Modelica Standard Libr
7. obtained Selecting a diagram makes it active Selecting Plot Delete Diagram removes the diagram Please note the usefulness of the Recent Windows button when working e g with a number of plot windows Clicking the button will toggle between the two last shown sub windows Clicking the arrow on the button displays a menu with all sub windows available plot animation diagram layer visualizer The menu alternatives for e g plot windows are based on the plot heading 1f specified or the names of the plotted variables Selecting a window from this menu will bring it to the top 3 TestMotor DriveLib TestMotor Plot 1 Angular velocity Pot LT y Fie Edit Simulation Plot Animation Commands Window Help mH QOS Mie Bi Ed ven o Aa AUE zb UW K 4i ib Timeo J Speed 1 Variable Browser motor flange b1 phi Variables Values zi TestMotor 1 motor Ra HG emf 20 Hs m 0 flange a Hflange_b J 0 001 Ikg m2 j m phi 0 rad der phi rad s 1 D rad s motor Jm 60 40 rad s rad sz V flange b1 phi tau N m step lt gt true 0 25 x simulateModel DriveLib TestMotor method dassl resultFile TestMotor true lt ammands Modeling y Simulation 1 4 6 Handling the warnings When simulating the TestMotor warnings can be seen by looking at the Translation tab of the Messages window
8. s Custom Translate gt gt Time Vanable ya Simulate Variables Continue it Descrptior LX Stop Lin arize Setup zt oo En visualize Show Log Dymola first translates and manipulates the model and model equations to a form suitable for efficient simulation and then runs the simulation You may explicitly invoke translation yourself by selecting Simulation gt Translate or click on the Translate toolbar button You will get a warning that the initial conditions are not fully specified The warning can be seen in the Translation tab of the Messages window that will pop However Dymola 24 Plotting the angle will select default initial conditions so the simulation will work We will discuss how to get rid of the warnings later For now you can just close the Messages window When the simulation is finished the variable browser displays variables to plot To see the plot better maximize the plot window in the edit window Then click in the square box in front of phi to get the angle plotted as shown below Pendulum Pendulum Plot y File Edit Simulation Plot Animation Commands Window Help i Ri e 2 46 moo ip Mo M 44 4E ib b Time Variable Browser Variables Values Pendulum 1 phi der phi OOONOOO W der w lt gt true true simulateModel Pendulum stopTime 10 method dassl resultFile Pendulum true Comma
9. J animationRedraw s true Bl Modeling W Simulation Animation toolbar Let us start to animate the robot Start the animation by selecting Animation Run or clicking the Run button on the toolbar the leftmost button BH 4 4I mo j Speed 1 v This toolbar contains the usual buttons of running pausing rewinding and stepping forward and backward respectively Also the time flow 1s shown and there is a possibility to set the speed of the animation higher figures means higher speed Please note that the Animation window can be maximized in the main window in the usual way If the Animation window by mistake is deleted a new can be displayed using the command Animation gt New Animation Window Direct manipulation of the view in the animation window using the mouse has been implemented The view can be moved rotated and zoomed using mouse movements in combination with Meta keys dragging on selected component up down left right Tilt Rotate around aa Up Down Up Down X axis Pan Rotate around Ctrl Left Right Left Right y axis Roll rotate around Ctrl Shift Clockwise Counter Left Right Z 7777 NR clockwise Zoom Zoomin out out Up Down Hebo Wheel Zoom in out Ctrl Right mouse button Up Down The arrow keys pan and tilt in fixed increments of 5 degrees in addition page up page down tilt 45 degrees The Home key resets viewing transformation Let us now look at
10. Model It is good practice to keep testing models Drag a Motor component from the package browser into the diagram layer of TestMotor We need a source for the signal input to the motor Signal sources are to be found in Modelica Blocks Sources Signal sources E Sources package Modelica Blocks Sources gt gt gt 69806 RealExpression IntegerExpression BooleanE pression Clock Constant Step Ramp Sine ExpSine Exponentials Pulse SawT oath Trapezoid KinematicPT P Er E EX OO lt Jil KinematicPT P2 TimeT able CombiTimeT able BooleanConstant BooleanStep BooleanPulse SampleTrigger NL 1D BooleanTable IntegerConstant IntegerStep RR jJ d Drag for example over Step to the model window and connect it to the motor step d startTime 0 motor Now it is time to simulate Click on the tab for Simulation This will change the mode from Modeling mode to Simulation mode To simulate the model click on the toolbar button Simulate Please note the difference v Simulation L Some warnings will be presented Please see next section on how to get rid of them However they are warnings so the simulation will work anyway To inspect the result we will first look at the angular position of the motor motor flange b phi Open motor in the variable browser by clicking on the sign Open the flange b and tick phi GETTING STARTED WITH DYMOLA 55 Angular position MU I dim 56 T
11. Re ven amp GicEPR BLI b MH M 4i ib DD rime Speed 1 w Variable Browser Ach phi phi Variables Values Pendulum 1 LILILI der phi W der w zi Pendulum 2 phi der phi W der w v lt gt _ phi 3 plot phi simulateModel Pendulum stopTime 10 method dassl resultFile Pendulum true Commands X Bl Modeling V Simulation Values of parameters are changed in a similar way To simulate another length of the pendulum just enter a new value for L and click on the simulate button 1 3 2 Improving the model Using pre defined physical quantities The parameters and variables are more than real numbers They are physical quantities The Modelica standard library provides type declarations for many physical quantities Using these instead of declaring variables parameters yourself gives two advantages e The declarations will be faster e Additional features will automatically be present e g units and limits So let us change the model using ready made physical quantities The starting point 1s the Pendulum model built previously If Dymola is not started start it and use File gt Open to open Pendulum mo E Press the Modelica Text toolbar button the second rightmost tool button to show the Modelica text layer GETTING STARTED WITH DYMOLA 27 28 Mark the declarations of variables parameters in
12. a documentation editor for the model class with text editing 52 Documentation editor The corresponding html source code possibilities as well as link creation and image insertion After insertion of some text an image and a link the result can look like Motor DriveLib Motor Documentation I File Edit iulatio Animation Commands Window Help uides LOC AM 5 Hm Z gt BBS Z io 2 24 iv l Ex 100 Package Browser zi X Text style Normal Bi by Ll 22 EL efe Packages This is a simple motor model H Lyra i utilities This documentation can certainly be extended using e g links and images of this editor An image of the a toolbar above illustrates the image possiblility H fa Constants j B Scons Text style Normal biu gEzzs ii N ce j B SIunits i LJ For more information about this editor please see chapter Developing a model in this manual Unnamed B priveLib More information about Dymola in general is Found in www Dymola com The created source code in html formatting can be viewed selecting Show Info source Motor DriveLib Motor Porumeptation IM File Edit iulation f tion Commands Window Help p SHa uo Y AB Lihjs e 2zHHBsE Package Browser B X lt html gt Packages F lt p gt This is a simple motor model lt p gt PUE Jeu lt p gt This documentation can certainly be extended using e g lt b gt link
13. axis axis2 axis3 axisControlBus1 HH REESE axis4 axis5 axis6 ll controlBus E Ee ee Modeling V Simulation The package browser in the upper left sub window displays the package hierarchy and it 1s now opened up with the robot model selected and highlighted The model diagram in the edit window the sub window to the right shows the top level structure of the model The model diagram has an icon for the model of the robot with connected drive lines for the joints The reference angles to the drive lines are calculated by a path planning module giving the fastest kinematic movement under given constraints GETTING STARTED WITH DYMOLA 7 About to view the me chanical structure of the robot The edit window displays by default the model diagram diagram layer but the user can select other information other layers to be displayed instead e g documentation or Modelica text For more information please see the chapter Developing a model The component browser in the lower left sub window also shows the components of the ro bot experiment in a tree structured view To inspect the robot model select the icon in the edit window red handles appear see below and right click press the button to the right on the mouse A menu pops that contains a selection of actions that can be made for the selected object a context menu From the context menu select Show Component fullRobot Mo
14. difference between the saved log and the content in the command log pane By saving as a mos file only executable commands are saved To run the script you have to be in Simulation mode The command Simulation Run Script or corresponding command button can be used to open execute the script Some comments e This script file is very simple just showing the idea of a script file rather than being a good example e Realizing how saving a script file works it is not necessary to start all over to create the file the total simulation can be saved and afterwards the script file can be edited to keep only the wanted parts of the simulation However it is important to test it if created that way e More information about script files is available in the chapter Simulating a model in the manual for more information e Working with scripting using functions is even smarter for more information please see the manual 1 5 Building a mechanical model We will now develop a more complex model a 3D mechanical model of a pendulum called a Furuta pendulum It has an arm rotating in a horizontal plane with a single or double pendulum attached to it see below 72 The Furuta pendulum The Parts sub package library window Start Dymola Open Modelica Standard Library In the package Mechanics open the sub package MultiBody This package includes 3D mechanical components such as joints and bodies which can be used to bui
15. down in the component hierarchy Dymola can assist you First you enter 0 5 and then you click on the small triangle to the right of the value field Select Insert Component Reference and then m GETTING STARTED WITH DYMOLA 67 Using Component load in DriveLib MotorDrive x Reference to enter a General Advanced Add modifiers formula Component Icon Inertia IN Mi om EE E E ER m Model J Path Modelica Mechanics Rotational Components Inertia Comment 1D rotational component with inertia load Parameters p T a 0E tdi w Initialization Edit Text Copy Default phi stark EN deq Absolute rotation anc k view Parameter Settings w skart H radis Absolute angular welt E Propagate astat p rad s Absolute angular acci peopud m Final gearbox 8 Insert Function Call phiload motor j load positionerror k Modi controller r You have now 0 5 m in the value field for J Enter Use the menus to get a reference to r Complete the expression with the square Click OK The model window now displays the expression for the load inertia The components pa rameter definition is visible in the model controller gearbox positionerror m J 0 5 m r 2 peajiud Open MotorDriveTest and switch to Simulation mode e Translate 68 A bound parameter cannot be changed in teractively comman True true
16. in this manual IT RI v More information about Dymola in general is Found in www Dymola com L i TackMaekex A JA a E Ra range o ge g g HG EE Name Motor emf Path DriveLib Motor tiVs Filename E Experiment DriveLib mo E Jm Uses Modelica versionz 3 1 La F Biflange bi The link can now be clicked by hovering on it the URL is shown in the status bar of Dymola main window bottom of window not shown in figure above The revision information can be edited in a similar way using Show Revisions editor We have now created the model Save it 1 4 5 Testing the model It is possible to check the model for syntactic semantic and structural errors Select Edit gt Check Hopefully your model will pass the check and you will get the following message Messages Dymola Syntax Error Translation Dialog Error Simulation version Management i Check of DriveLib Motor The model has the same number of unknowns and equations 48 Check of Drivelib Motor successful The connector inPort defines the voltage reference and should be defined for the complete model but is viewed as a known input to the model It is important to test all models carefully because that eliminates tedious debugging later on Let us connect the motor to a voltage source Create a model called TestMotor and insert it into DriveLib The easiest way is to use the command File gt New gt
17. model Set ratio to 3 as indicated It means that the motor load rotates 3 times slower than the DC motor The library Modelica Mechanics Rotational Sensors contains a sensor for angles Inserting a load was dealt with when building the motor model GETTING STARTED WITH DYMOLA 61 The completed motor drive 62 MotorDrive DriveLib MotorDrive Diagram E File Edit Simulation Plot Animation Commands Window Help E X in R idadi S Hau Z h BEBE Zio v Package Brow f Packages ptal JUQUCUIl apii ES C Thermal i CI Utilities Unnamed I m DriveLib Motor Test otor MotorDriveT est pee i Ess x Component Bror 7 controller position Components 3H positionerror s controller motor phiload i load 3 gearbox DriveLib MotorDrive Modeling y Simulation To test the model MotorDrive for normal operation we need to define a reference for the position This can be done in different ways A simple approach is to add a signal source di rectly to MotorDrive However we may like to use MotorDrive also for other purposes If we would like to use the drive as a component we could add a connector for the reference as we did for the electric DC motor model However here we will take the opportunity to show another useful way namely use of extends We will develop a new class say Motor DriveTest which extends MotorDrive Select MotorDrive in the package browser
18. positive x direction This is specified by setting the vector r between the two ends of the body to 0 5 0 0 Click on the Edit icon just to the right of the value field of r and a vector editor pops up Enter 0 5 in the first field 0 in the following two fields you must specify the values since no default values are shown otherwise you later will get an error message Click OK The width and height will be 0 1 by default To get nicer animation you can set different colors for the bars For example use the list of choices of color to make the bar red From the bar B1 we connect another revolute joint R2 having a horizontal axis of rotation n 1 0 0 and a BodyBox B2 rotated 90 with r 0 0 5 0 and a different color than the first bar When simulating the start values of R2 are interesting Looking at the parameter dialog for R2 the initial value of the angle phi start the initial velocity w start and the relative angular acceleration a start can be specified in the dialog The idea is of course to specify values when simulating but we have to specify what type of start values we want to use This 1s done by clicking on the box after each start value The choices are GETTING STARTED WITH DYMOLA 15 Fixed Choices for start True start yalue is used to initialize values False skart value is only a quess value wv Inherited False start yalue is only a quess value Actually we don t need to change anythin
19. ptas 2a LA Using the Mod lica Standard LADEAE esorare E dads Moves a ed 33 1 4 1 The Modeliea Standard EIDEOEV coil ERE obe die rcd TRE 34 1 4 2 Creatine a ibrary LOR COMMON IES s ni ad bd nb dimid da Vaid tud atm uide 42 1 4 3 Creatine a model toramtelectdc DG MOTOR eid edd d di did medida ti dea ue 44 1 4 4 Doc rnient me the THOGels eoo eene tb a erate eee eee eu te ee 5 1 4 5 Testine the THOOel ir cabin Pautas testas oc tea aba dU Led is c e LP pe dU Md Ne ILU 54 1 4 6 HandliiP ihe WAabtiitig Siessen ob baies ea ARN dac RD DM Mei 57 1 4 7 Creatine danodel for The THOLOT CIV S cise isc atop atas b tiia Mi ssa e o a ute etie eti ates Lote 61 1 4 8 Parameter CXL CS SEONG oie obe dodo E Siac clea chive diuites a eee 64 1 4 9 Documenti the smao Ne il eu Spe Nutev dL uU URDU s Iu Eno LED Mta ET DUREE 69 DALO osos RC eH r ccccc eee 71 L5 DBu uikinga mechanical Model nee S a ei tau lta a N 72 IE MEG Sd MERETUR 78 1 6 1 Libraries available in the File menu by default cccccccccccsscccccccccccccccccccccccccecccecccccceecececcceeeceeeeeees 78 1 6 2 Isibrariessthat Cat Dead Ge ciirsa a 79 Lv Bep and difotpnatiobz ooa E ADEM on ree eR rn n Edu ee AU dE LAM E EE 79 1 7 1 Reachitie compressed irr rial Oi eases ones NER tte AEA E E A E A EA UE E UTE EN 79 1 1 1 Modeling Getting started with Dymola Introduction V Simulation This chapter will take you through some examples in order to get you started with D
20. r Parameter declara tions added to motor drive The parameters and variables are more than real numbers They are physical quantities The Modelica standard library provides type declarations for many physical quantities Select Open Modelica SIunits by clicking on it in the package browser note do not open it MotorDrive should still be open For the parameter r which is a radius it 1s natural to declare it as being of type Radius To find it enter r and the browser goes to the first component starting with r R If it is not the desired one press r once again and so on to find it When you have found Radius drag it to the component browser below The choice to add a component is pre selected Click OK A menu to declare a variable pops up Complete the declaration do not forget to change to a parameter Declare variable E _ Declaration Type Frefix Annotations Type and name dea Suns Radus J C s Description Radius of load Modelica parameter Madelica SIuniEs R adius r 20 5 Radius of load Click OK and the text appearing in the bottom row is inserted into the Modelica text win dow The parameter m being 80 kg if the resulting inertia should be the same as previously is defined in an analogue way MotorDrive DriveLib MotorDrive Modelica Text Sele Ej File Edit Commands Window Help ax as em od d A J P s nno cde YM NYOOCVA
21. the components of the selected sub library are displayed in a part of the window By closing the package browser by toggling the button to the bottom left double clicking on the icon for Modelica and adapting the window to the content the following will be displayed Please note that now the name of the package will be displayed in the window title bar A library window dis playing the compo nents of the Modelica Standard Library The rotational mechan ics library window Modelica package Modelica Seles Jae E EDEN e UsersGuide Blocks Statecraph Electrical Magnetic Mechanics Fluid tray ray Pe Mabe Media Thermal Math Utilities Constants SIunits By using the right button at the bottom it is possible to go up in the package hierarchy and by double clicking on the icons in the window it is possible to go down in the hierarchy The left and right arrow buttons allow going back and forth as in an ordinary web browser Open Modelica Mechanics Rotational in the library window by first double clicking on the icon for Mechanics and then on the icon for Rotational The package Rotational contains components for rotating elements and gearboxes which are useful for our modeling of the electrical motor drive Rotational package Modelica Mechanics Rotational PREIES Users 7 T UsersQuide Examples Components Sources Sensors Interfaces LL R J Z The Info for Modelica Mechanics Rotational
22. value is generic and that it ought to be set by the user More about such warnings can be read in chapter Developing a model section Advanced model editing sub section Parameters variables and constants The way to handle this is to double click on the emf component and set the value of k to 1 emf in DriveLib Motor If General Add modifiers Component Name emf Comment Model Path Modelica Electrical Analog Basic EMF Comment Electromotoric Force electric mechanic transformer Parameters useSupport true if support Flange enabled otherwise implicithy grounded k ap M mj Transformation coefficient Click OK to confirm the change When simulating again no warnings will be given 1 4 7 Creating a model for the motor drive The task was to build a model for a motor drive and it ought now to be a simple task to com plete the model We will just give a few hints Note that the full names of the components are given in the component browser at the lower left Give the model the name MotorDrive we will refer to that name later on Put it in DriveLib To generate the position error you may use the model component Modelica Blocks Math Feedback For the controller there is Modelica Blocks Continuous PID In this simple example we can select the component Modelica Mechanics Rotational Components IdealGear as gearbox For the meaning of ratio for the gearbox model please consult Info for the
23. Before building the motor model please note that selecting a package in the package browser by just clicking on it does not mean that it 1s the one that 1s displayed in the edit window and component browser Yes it is indicated in the package browser by blue or red if not saved but the one displayed stays the same and is indicated by a blue frame in the package browser the name in the window header the top name in the component browser and the name in the bottom left in the window By double clicking or right clicking on the package in the package browser the displayed package is changed however We will now start building the motor model To make it easier to follow the instructions the result is displayed below The finished motor model with all compo nents flange b1 We need a model component for a resistor It can be found in Modelica Electrical Ana log Basic The basic approach is to use drag and drop You can drag and drop from the package browser or from a library window To drag from package browser open in turn Modelica Electrical Analog and Basic Note that title of the Dymola window is still DriveLib Motor and also the component browser has DriveLib Motor as top level to indicate that we are editing the motor model About to drag a resis Motor DriveLib Motor Diagram DE tor from the package _ ax iE File Edit Commands Window Help browser eHQASGw NOOVAE SZ 2 HM s H 9 BABE io Package B
24. DriveLib MotorDriveTest Plot J File Edit Simulation Plot Animation Commands Window Help tm QOS We 100 Be ven msnm H i bM M 44 4I ib Teo Speed 1 Variable Browser x phiload phi step y Variables Values positionerror controller Nd initT ype start xd start y start WP Hl HD Gain Add motor gearbox load ziphiload xi flange v phi rad zistep height llrad My rad offset Alad gt l phiload phi in MotorDriveTest mat E Modeling V Simulation The interested reader may next proceed to tune the controller parameters to obtain a nice step response For example aim at a rise time around 0 4 seconds a settling time around 1 second maximum overshoot of 10 percent and a maximum control signal magnitude of 100 Enforce the last constraint by adding a Modelica Blocks Nonlinear Limiter component between the controller and the motor in the MotorDrive model Set uMax 100 and uMin 100 for the limiter We will not show this component in the code The result might be something like GETTING STARTED WITH DYMOLA 63 Tuning result 64 MotorDriveTest DriveLib MotorDriveTest Plot 1 1 y File Edit Simulation Plot Animation Commands Window Help toilla 22 Bho Bevel o AEK ELI Speed 1 P TL M ED Times Variable Browser phiload p
25. Dymola Dynamic Modeling Laboratory Getting started with Dymola Contents Chapter 2 Getting started with Dymola extracted from the manual Dymola User Manual Volume 1 May 2011 The information in this document is subject to change without notice Copyright 1992 2011 by Dassault Systemes AB All rights reserved Dymola is a registered trademark of Dassault Systemes AB Modelica is a registered trademark of the Modelica Association Other product or brand names are trademarks or registered trademarks of their respective holders Dassault Syst mes AB Ideon Science Park SE 223 70 Lund Sweden E mail Dymola Support 3ds com URL http www Dymola com Phone 46 46 2862500 Fax 46 46 2862501 Contents I Gettmp started with Dyimola sie EIE EIE aA NEDRa a EROR IRE ERES SE Ev ESEE EEO S 5 Tel ADSHEOOUIC LIOS eemfsteia E os puteo uideat totcu tecum Gaudete io SORPUU ie eto RD date M MESE CURE E 5 12 Simulating atid Gl md strial rob t iu ettet Snes Nesta nad Peste a deese hes Va etica edes sare ed bet aes 6 L21 IB CERT ET OTI osos mno rois eos cumes etta tete uud Asan ate aris nesMad became aeoe al rede nit ed bed uota dnas pea tacvitd tod od eiu ied 15 1 22 Other demo examples aeara ET E E 19 L3 Solwmnpanon Imear differential equation eos tdeo eet E ot RR Dee s Ree bes TEE Ta ERA a EEE 20 1 3 1 VIDURINLE NIU D T OD DT 23 1 3 2 Improving the mode onsddexarsn bod Om arae dd add m ta amd ded add dn tud midst
26. E connect positionerror y controller u a dE connect motor flange bl gearbox flange a a4 Components connect gearbox flange_b load flange_a a Privelib MotorDrive 1 connect load flange b phiload flange 3 gearbox connect phiload phi positionerror uZ n5 phiload connect controller y motor vl ns motor end MotorDrive Hload ipositionerror controller Ok now activate the diagram representation Double click on the load icon to open the parameter dialog Binding a parameter to an expression load in DriveLib MotorDrive Test kJ E3 General Advanced Add modifiers Component Mame load Model Path Modelica Mechanics Rotational Components Inertia Comment 10 rotational component with inertia Parameters J 2 kgme Moment of inertia Initialization phistat hf deg Absolute rotation angle of component w atat th rad s Absolute angular velocity of component der phi a start r th rad sz Absolute angular acceleration of component der w Click in the value field of J and enter the expression for J Click OK The model window now displays the expression for the load inertia When entering the expression you are sometimes not sure about the exact name of the variables names for example is the radius called r r0 or r1 The problem is even more pronounced when you would like to reference a variable a bit
27. EBS 2 Z 98 e gt 2S BES os Package Browser mx model MotorDrive Packages q tm i FWaveNumber i b parameter Modelica SIunits Radius r 0 5 Radius of load i CircularWaveNumber i parameter Modelica SIunits Mass m 80 Mass of load AmplitudeLevelDifference equation PowerLevelDifference amp M DampingCoefficient and MotorDrive LogarithmicDecrement AttenuationCoefficient j PhaseCoefficient F PropagationCoefficient Damping i Mass CE EJT J LX In Modelica Text representation above the components and connections are indicated by in the margin to the left of the text and icons in the text It is possible have them expanded textually in two ways One way is to work with individual annotation It is possible to click on the or the corresponding icon to expand that annotation but no other If sub annotations are present GETTING STARTED WITH DYMOLA 65 Expanded text representation 66 new and icons will be visible which in turn can be expanded Of course they can also be compressed using The other way is to work with all annotations at the same time If that is wanted right click and select Expand Show components and connect It is also possible to expand the annotations such as the graphics for the icon of the model the positions and sizes of the icons of the components the path of the connections etc This is done by right clicking and
28. GearAeT IdealRiallingw heel InitializeFlange Rlelatrve States To get a model window for Inertia select Open Class in New Window in the same context menu A window for the model Inertia is created Switch to the Modelica Text representation where you find Euler s equation as the last equation Mathematical defini uuum Modeles Mechanics Rotational tpmpenente Inertie Read Only Modelica Text tion of a rotational in E File Edit Commands Window TEM 5 X m T ertia wide uocANEZ 3n s S e zHBs Package Browser mx model Inertia lD rotational component with inertia Fr import SI Modelica SIunits p PPE HmBmeta 00000000 parameter SI Inertia J min 0 start 1 Moment of inertia parameter StateSelect stateSelect StateSelect default Priority to use phi and w as states g H eweSpring SI Angle phi stateSelect stateSelect Absolute rotation angle of component Pod SI nqularVelocity wistateSelect stateSelect PeprEeDamper 291 i i i Absolute angular velocity of component der phi a P 4e SpringDamper SI nqular cceleration a iheElastoBacklash it Absolute angular acceleration of component deriw a P EreearingFriction B a i Brake quation i owe phi flange a phi gea w der phi a der w Cp ax J a flange a tau flange b tau Components end Inertia Modelica Mechanics Rotational Component r Mifl
29. R_ref 1 alpha iheatPort T T ref true iF HeatPort is enabled alpha useHeatPort Fixed device temperature if useHeatPort False Change the component name to Ra The parameter dialog allows setting of parameter val ues To set the resistance parameter R select the value field of parameter R and input 0 5 The parameter dialog of a resistor with new settings resistor in Drivel ib Motor General Add modifiers Component Model Resistor Path Modelica Electrical Analog Basic Resistor Comment Ideal linear electrical resistor Parameters R i Resistance R ref at temperature T ref T ref Reference temperature Temperature coefficient of resistance R_actual R reF 1 alpha heatPort T T ref useHeatPort true if HeatPort is enabled alpha Fixed device temperature if useHeatPort False Click OK Similarly drag an inductor to the Motor window Name it La and set the inductance L to 0 05 Drag a ground component into the motor model Name it G The ground component is as important as in real electrical circuits It defines the electrical potential to be zero at its con nection point As in the real world never forget to ground an electrical circuit Drag an electromotive force EMF component into the motor model Keep the name emf The component is grounded meaning that the component has a support where the support connector is fixed to the ground Please keep in min
30. TED WITH DYMOLA 43 Drivelib created DriveLib DriveLib Modelica Text SEE E File Edit Commands Window Help 8 X a d OQ 6 N2 L10 07 AB o Z 88 4 BB ME S o Package Browser Bx package DriveLib i MEM Packages le Mechanics end DriveLib m Fluid Media 7 Thermal peh _ 7 utiities z Constants j gglicons j JStunits Unnamed amp jeje Component Browser m el X Components 1 4 3 Creating a model for an electric DC motor An electrical DC motor flange b1 A model of the complexity indicated above will be developed for the electric DC motor For simplicity the voltage supply is included in the motor model The model includes an ideal controlled voltage source The electric part of the motor model includes armature resistance and armature inductance The electromotive force emf transforms electrical energy into ro tational mechanical energy The mechanical part includes the mechanical inertia of the mo tor Let us start building the motor model Select in the Dymola window File New Model Enter Motor as name of the new model To have the Motor model being a part of DriveLib 44 Inserting Motor in Drivelib we need to enter DriveLib for Insert in package This can be done in several ways Dymola provides alternatives to be selected from and DriveLib 1s an available alternative There are no other alternative because all other open pac
31. To get more information select Simulation Setup or click directly on the Experiment Setup toolbar button click on the Translation tab and check Log selected default initial conditions Simulating yet another time and looking the Translation tab of the Messages window will yield GETTING STARTED WITH DYMOLA 57 58 Messages Dymola Syntax Error Translation Dialog Error Simulation version Management Translation of DriveLib TestMotor The DAE has 50 scalar unknowns and 50 scalar equations Warning The initial conditions Far variables of type Real are not Fully specified Assuming Fixed default start value Far the continuous states motor Im phifskart 0 motor Jm wistart D motor La iistart 0 Warning The initial conditions are not Fully specified Dymola has selected default initial conditions LogDefaultInitialConditions true gives more information STATISTICS Original Model Number of components 11 Variables 64 Parameters 14 14 scalars Unknowns 50 50 scalars Differentiated variables 4 scalars Equations 44 Montrivial 33 Translated Madel Constants 9 scalars Free parameters 10 scalars Parameter depending 2 scalars Continuous time states 3 scalars Time Varying variables 11 scalars Alias variables 32 scalars Assumed default initial conditions 3 Number of mixed realfdiscrete systems of equations 0 Sizes of linear systems of equations 4 Sizes after manipulation of the linear sy
32. Volume 2 chapter Design optimization e Model validation supports validation and regression testing of a specified model The idea is to compare the simulation result against reference data to check if for example changes in model libraries change the result The reference data is assumed to be stored as trajectory files which is the data format used by Dymola to store simulation results When developing a model it is very natural and recommended to provide it with carefully checked reference simulation results Please also compare the library Model Management where model validation and regression testing is supported on a larger scale Plot 3D is used to visualize models in 3D This library 1s free Modelica LinearSystems2 is a free library from Modelica Association providing different representations of linear time invariant differential and difference equation systems as well as typical operations on these system descriptions See the documentation inside the package for details Modelica StateGraph2 is a free library from Modelica Association providing components to model discrete event reactive and hybrid systems in a convenient way with deterministic hierarchical state diagrams It can be used in combination with any Modelica model It has larger power than the package StateGraph in the Modelica Standard Library See the documentation inside the library for details VehicleInterfaces is a free library providing standard interfa
33. a rameters Edit gives a matrix editor function call editor Edit Text gives a larger input field etc An example is that for the first parameter useAxisFlange the command Edit Text can be used to enter an expression that should be true in order for the axis flange to be enabled If such an expression is entered the checkbox will be displayed as m Some parameters have a list of choices where you can select values instead of writing them One example is the parameter n which defines the axis of rotation The value for this revolute joint is 0 1 0 1 e the axis of rotation is vertical Parameters useAxisFlange true if axis flange is enabled animation atrirnations 8 true if animation shall be enabled show axis as cylinder A Axis of rotation resolved in frame a same as in frame bj Initialization H D D x axis phi start 10 10 y axis Relative rotation angle fram frame a to frame b Ww shark 1001 aes First derivative of angle phi relative angular velocity l 11 0 07 negative s axis SEE a start 0 1 0 negative y axis Second derivative of angle phi relative angular acceleration 0 0 1 negative z axis To learn more about the component select Info An information browser is opened to show the documentation of the revolute joint Links in the document makes it easy to navigate to e g the description of the package containing the revolute joint Now please close the browser and press Cl
34. access to the sub libraries We will need components from various sub libraries We will need rotational mechanical components as well as electrical components for the motor To open the Modelica Mechanics double click on Mechanics in the Package browser The documentation layer of the library will be shown If not click on the Lil in the upper toolbar Opening Modelica Me Mechanics Modelica Mechanics Read Only Documentation Sele chanics Mj File Edit Commands Window Help ISX sugan xoog A E Z Ay 4 gt m e EV EI a 100 Package Browser B Xx Library of 1 dim and 3 dim mechanical components multi body rotational translational Packages E Medelica F 6 ser s Guide This package contains components to model the movement of 1 dim rotational 1 dim translational and 3 dim mechanical systems Information j qq Blocks E Estate Graph Extends from Modelica Icons Library2 Icon For library where additional icon elements shall be added fea Electrical Package Content H ej Magnetic I Mechanics S Mechanics MultiBody Library to model 3 dimensional mechanical systems MuliBody Rotational Library to model 1 dimensional rotational mechanical systems i Translational Library to model 1 dimensional translational mechanical systems Name Mechanics Path Modelica Mechanics Filename C Program Files Dymola 7 3 Modelica Library Modelica 3 1 Mechanics Version 3 1
35. agram It is also important to document the model When creating the model the dialog has a slot Description It is possible to edit this after wards Select Edit gt Attributes to open the dialog GETTING STARTED WITH DYMOLA 51 Model attributes Change attributes for Motor General Graphics Version D escriptian 4 basic model of an electrical matar Restricted class O Class Block Model Function Connector Package O Record Expandable connector Properties Encapsulated Partial Protected Replaceable Store as one file Dynamic typing Normal Inner Outer Cancel Enter a description and click OK n A longer documentation can be provided in the following way Click on the toolbar button for Documentation the button between the Diagram button and the Modelica Text button Documentation View Motor DriveLib Motor Documentation I File Edit Commands Window Help c EOM VNYOOVABYZ 2 Z ia gt BERG amp o Package Browser Bm X A basic model of an electical motor Packages Pe Jeu Connectors stunts Unnamed Name Motor Path DriveLib Motor priveLib Filename ave E worsen v To enter a description put the cursor in the window Right click and select Show gt Info editor You now have access to
36. ameters J 0 001 kgm Moment of inertia Initialization phi stark w deg Absolute rotation angle of component wskark w 7 radis Absolute angular velocity of component dertphiy astatt 1 rad s2 Absolute angular acceleration of component der w Click OK to confirm the changes The last variable of the upper warning section is located in the inductance component La Double clicking on this component will however not display any Initialization section But since the variable is known we can click on the tab Add modifiers and enter the text i fixed true and press OK GETTING STARTED WITH DYMOLA 59 60 La in DrivelLib Motor General Add modifiers 4dd new modifiers here e g phifstart 1 wistart 2 ifFixed true When having clicked OK the General tab will change to present the new initialization information Double clicking again on the inductance component will result in La in DriveLib Motor General Add modifiers Component Icon Mame La Inductor Model L Fath Modelica Electrical Analog Basic Inductor Comment Ideal linear electrical inductor Parameters Initialization istart v FA Current Flowing From pin p Eo pin n If simulated again the upper warnings in the Translation tab will not be present any more The lower warning states that the parameter motor emf k start 1 only has a start value start 1 but no value The warning implies that this parameter
37. and select Edit gt Extend From in the context menu This gives the same dialog as File gt New gt Model but with several fields filled out It extends from MotorDrive and is inserted in the same package DriveLib Enter MotorDriveTest as the name of the model Click OK The result is a model window where the diagram layer looks exactly like that of MotorDrive However the components cannot be edited Try to move or delete a component It has no effect Drag over a component Step from Modelica Blocks Sources and connect it Save the model A model can be used for different tasks One is tuning the controller manually Click on the tab for Simulation Translate the model MotorDriveTest by clicking on the Translate button Also delete one of the plot windows and delete the previous curve The PID controller has four parameters k Ti Td and Nd There will be some warnings when translating We will take care of those later Tuning the controller One way to tune a PID controller is by first disabling the integrator and derivative parts This is achieved by setting a large value for Ti and a small value for Td Set k 2 T1 1000 and Td 0 001 and simulate for 5 seconds Use Simulation gt Setup to change the stop time As can be observed the step response is very slow Increase k to find out what happens Make sure to also investigate the magnitude of the control signal controller y The result will be 3 MotorDriveTest
38. ange_a Wiflange b If wanted it is possible to look at the content with equations rendered with mathematical notation Right click to pop the context menu and select Use mathematical notation The result will be GETTING STARTED WITH DYMOLA 41 Displaying using mathematical notation Inertia Modelica Mechanics Rotational Components Inertia Read Only Modelica Text PEE Ej File Edi Commands Window Help B X amp uoaevulovANBZS E 95 e 2HBB o Package Browser Bm x model Inertia 1D rotational component with inertia import SI 2 Modelica SIunits Packages j dene o O parameter SI Inertia J min 0 start 1 Moment of inertia ijji parameter StateSelect stateSelect StateSelect default P P Disc Priority to use phi and w as states PL dicen SI Angle phifstateSelect stateSelect Absolute rotation angle of component POT pring SI AngularVvelocity w stateSelect stateSelect i repreDamper Absolute angular velocity of component der phi P SI AngularAcceleration a 42 gt SpringDamper Absolute angular acceleration of component der w atlheeElastoBacklash ii flange iF Sr BearingFriction Bra 2 GbBrake p flanges Bi d EN v ca A i i P x m E ooo gt Lr dw a gt Component Browser Gf x df Components J a flange z flange t Modelica Mechanics Rotational Component F lllflange a end Inertia t Miflange b After this introducti
39. ary 33 34 Modelica text layer text size 22 moving animation view 17 P pan animation view 17 parameter dialog 10 propagation 64 pendulum 20 84 plot window 16 propagation of parameters 64 R roll animation view 17 rotate animation view 17 rotation center of animation 17 run script 16 S script 16 71 scroll animation view 17 setting parameters 27 simulate model 24 simulation 15 documentation 69 setup 23 start values fixed 32 syntax check 22 T text size 22 translate model 24 W warnings 31 57 64 See also errors window animation 16 diagram layer 17 plot 16 Z zooming animation window 17
40. ce definitions for automotive subsystems and vehicle models to promote compatibility between the various automotive libraries See the documentation inside the library for details 1 6 2 Libraries that can be added There are a number of libraries available both free and commercial ones For an overview of them please see http www modelica org libraries Help and information 1 7 1 Reaching compressed information The What s This command button etc The What s This command is used to display information about many things The command is activated in three different ways depending on where is should be used GETTING STARTED WITH DYMOLA 19 80 In the Main Dymola window Dymola Dynamic Modeling File Edit Simulation Plot Animat aad Deb MG 0m Package Browser If more information should be obtained for e g a button or a symbol in the Dymola main window the easiest way is to click on the What s This button and then click on the symbol that is of interest The Help menu can also be used to activate this function Please note that this button does not work in the Edit window In any dialog Dymola In any dialog the What s This is reachable using the in the upper corner of the window Click on the and then on the field of interest Please note that sometimes the information concerns only exactly what has been clicked on sometimes the information concerns a group of signals etc In any menu When disp
41. chronized to give a consistent view When you select a component in the edit window it is also highlighted in the component browser and vice versa The diagram layer of the edit window gives the component structure of one component while the The mechanical struc ture of the robot component browser gives a more global view useful to avoid getting lost in the hierarchical component structure The edit window now displays the mechanical structure consisting of connected Joints and masses The component browser is opened up to also show the internals of the mechanics model component fullRobot Modelica Mechanics MultiBody Examples Systems RobotR3 fullRobot Diagram File Edit Simulation Plot Animation Commands Window Help iw Hae NEN mopy AEL amp th Package Browser Packages a gi User s Guide of MultiB ody Libr iij word Examples 7 Elementary 3 fM Loops z Rotational3DEffects zi 7 Systems zi RobotR3 _JJoneAxis Component Browser Components zi Modelica Mechanics MultiB ody Example mechanics B axis li axis2 li axis3 E axis4 E axisd E axis6 world Hri 3 r2 3 r3 Modeling y Simulation Double click on for example rl at the bottom of the edit window This is a revolute joint The parameter dialog of that component appears The parameter dialog can also be accessed from the right button menu Double clicking the left button selects th
42. contains important information on the package content By navigating in the packages libraries present here using double clicking and left arrow we will find a number of components that might be of interest to us As examples this is how the libraries Components and Sensors will look like GETTING STARTED WITH DYMOLA 39 The Components Components package Modelica Mechanics Rotational Components library IN BN E a amp o ai Po e re ep 17 o un Fined Inertia Disc Spring D amper Sprngbamper ElastoBacklash ES a ne Han m _ noo amp E c a n alls Tm E Eri E E BearingF riction Brake Clutch Onew ayClutch Ideal 3 ear Lossy aear IdealPlanetary Gearbox IdealaearR2T IdealRolling heel InitializeFlange RelativeStates The Sensors library Sensors package Modelica Mechanics Rotational Sensors Ce Or Ox XD CSS AngleSensor SpeedSensor AccSensar FRel4ngleSensor RelSpeedSensor Hel ccSensar TorqueSensor power PowerSensar A quick scan of the Component library indicates that the model Inertia may be of interest for us Right click on Inertia for a context menu Select Info to get documentation for the model 40 The context menu for Components package Madelica Mechanics REotational Components a component PA class i in Mew Window ot fb Damper Spring amper mi Al mo ce m ae E E BearingFrictian Clutch OneWayClutch IdealG ear LossyGear IdealPlanetary Gearbox Ideal
43. d the difference from electrical grounding A voltage source is to be found in Modelica Electrical Analog Sources Use a library win dow or package browser to locate it Select SignalVoltage and drag it to the model window of Motor Name it Vs Let Vs be selected and use Edit gt Rotate 90 to turn the signal input Vs inPort from a top position to a left position SignalVoltage produces between its two electrical pins p and n a voltage difference p v n v that is equal to the signal input This info can be displayed by right clicking on the icon and selecting Info To get the proper sign we would like to have pin p in the top position Since the pin p is the filled blue square we must flip the component To do that use Edit gt Flip Vertical A rotating inertia component is to be found in Modelica Mechanics Rotational Components Drag and drop such an inertia component Name it Jm and set the inertia parameter J to 0 001 GETTING STARTED WITH DYMOLA 49 50 Now all model components are in place Components are connected by drawing connections between connectors Connect the resistor to the inductor by pointing at the right connector of the resistor the small white square press the left mouse button and keep it pressed while dragging it to the left connector of the inductor The resistor and the inductor are now connected and the graphical result is a line between them When connecting the voltage source and the resi
44. del in the manual Note that math rendering of equations etc is supported including indexing and Greek letters e The command log pane is enlarged the command window can also be undocked instead using the Undock button 70 e The header the lines with double brackets and the last line is entered by the user the rest is automatically output from the system if the user has given a simulation command and a plot command e A plot is not included unless some change has been made and the plot is considered finalized e g by giving another command To force the system to include a plot anyway deselect select a variable plotted in the variable browser and click in the command input line Then the system recognize a change a finalize and inputs the plot e The content of an animation window can also be included using another flag e Sections of the command log pane can of course be copied to e g Microsoft Word for further work e The content of the command log pane can be saved as a command log in Dymola in various formats and including various contents 1 4 10 Scripting Scripting makes it possible to store actions for various reasons Examples might be e The script can be used to run a demo e The script can be used for testing of e g different parameter sets e The script can be used as an action that can be included in other models The first item can be solved creating a script file while the last one is bes
45. delica Mechanics MultiBody Examples Systems RobotR3 fullRobot Diagram File Edit Simulation Plot Animation Commands Window Help Oe Mu o noogAMI 5 ihns 35 8PBZ v Package Browser MEX 2 J 87 x Packages 4 we E d gi User s Guide of MultiBody Libr iij word Examples 7 Elementary 3 M Loops S H CI Rotational3DE ffects zi M Systems zi RobotR3 C oneAxis gt Lew pathPlanning mechanics Parameters Component Browser x controlBus 3 Show Component Open Class in New Window Attributes m a Change class Components Model Mechanics MuliBody Examples Sy mechanics pathPlanning axis axis2 axis3 axis4 axis5 axis6 lll controlBus Er EE EH Info Edit annotation axisControlBus1 E E Ec EH EE Modeling Y Simulation N It is not necessary to select the robot component explicitly by first clicking with the left button on the mouse on it to access its menu It is sufficient to just have the cursor on its icon in the edit window and right click The component browser also gives easy access to the robot component Just position the cursor over mechanics and right click to get the context menu for mechanics The component browser provides a tree representation of the component structure The edit window showing the diagram layer and the component browser are syn
46. dit gt Rotate 90 This just changes the appearance of the icon Double click on the icon Change the name to R1 The axis of rotation is set as the parameter n We would like to have a vertical axis of rotation use the list of choices and select y axis Click OK Connect the connector of world to the bottom connector of the revolute joint revolute in Unnamed General Animation Advanced Add modifiers Component Icon Name Revelute Model Path Modelica Mechanics MultiBody Joints A evolute Comment Revolte joint 1 rotational degree af freedam 2 potential states optional axis flange Parameters useAwisFlange true if asis flange is enabled animation true if animation shall be enabled show axis as cylinder n Axis of rotation resolved in frame a same as in frame b Initialization LOO y axis phi start 1 LOT y axis k Relative rotation angle from frame a to frame b 10 0 17 z axis 11 0 07 negative x axis a start 0 1 0 negative y axis Second derivative of angle phi relative angular acceleration 10 0 1 negative z axis wy start First derreative of angle phi relative angular velocity A bar is then connected to the revolute joint There is one bar which has the visual appear ance of a box during animation called BodyBox in the Parts library Drag over a compo nent Double click on the icon Name it Bl We would like the bar to be 0 5 long and initially horizontal and pointing in the
47. e end nglel 60 de end ngle2 70 de end ngle3 35 de end ngle4 45 de end ngle5 110 de end ngleS 45 de refSpeedMax 1 3 rac refSpeedMax 2 1 5 ra refSpeedMax 3 5 rat refSpeedMax 4 31 rac _ refSpeedM ax 5 3 1 rac refSpeedMax 5 4 1 rac ref amp ceMax 1 15 rac ref amp ceMax 2 15 rac ref amp ceMax 3 15 rac ref amp ccMas 4 60 rac ref amp ccMax 5 60 rac ref amp ccMas 5 60 rac kpl 5 ks1 05 E Tsl 0 05 s kp2 5 ks2 0 5 1T 2 0 05 s L kp3 5 L ks3 0 5 L Ts3 0 05 s L kp4 5 L ks4 0 5 L Ts4 0 05 s kp5 5 v lt il gt animationRedraw E true c true lt Jill gt Modelica Mechanics MultiBody Examples Systems RobotR3 Components AxisTypel B Modeling V Simulation T Now the diagram layer is visible You can now navigate exactly the same way as in the Show Component Modeling mode right click on the component you want to look into and select Show Specs nes Add Component to look into it You go back using the Previous button the leftmost button in Show Variables the toolbar figure to the left Attributes BE nee If you want the diagram layer to show more of an overview e g the whole robot you have 23 to go back to Modeling mode and change what is displayed in the Edit window Then you Ege annotation can go back to Simulate mode When having reached the i
48. e first alternative from the right button menu GETTING STARTED WITH DYMOLA 9 Parameter dialog mechanics r1 in Madelica Mechanics MultiBady Examples Systems REobotR3 f ulla hot Component Icon Mame mechanics 1 Revelute coment 00 Model Path Modelica Mechanics MultiB ady J eints A evolute Comment Revolte joint 1 rotational degree af freedam 2 potential states optional axis flange Parameters Used wisF lange true if axis flange is enabled animation animation isle true if animation shall be enabled show axis as cylinder n T Asis of rotation resolved in frame a same as in frame b Initialization phi start deg Relative rotation angle fram frame a to frame b w start rad s First derivative of angle phi relative angular velocity a start rad s Second derivative of angle phi relative angular acceleration The parameter dialog allows the user to inspect actual parameter values In demos the parameter values are write protected to avoid unintentional changes of the demo example then the dialog just has a Close button and an Info button When the parameter values can be changed there is one OK button and one Cancel button to choose between The values are dimmed to indicate they are not given at the top level model but somewhere down in the component hierarchy A parameter dialog may have several tabs This dialog has the tabs General Animation Advanced and Add modifiers In a tab the para
49. e of w to zero The resulting code generating no warnings will be model Pendulum parameter Modelica SIunitzs Mass m l1 Mass of the pendulum parameter Modelica SIunits Length L l Lenght of the pendulum parameter Modelica SIunits cceleration g 9 81 Gravity of acceleration parameter Modelica SIunitz Moment flnertia J m L z Moment of inertia Modelica SIunits Angle phi start 0 1 fixed truse Pendulum angle Modelica SIunits nqularVelocity wistart fixed true Angular velocity equation deri phi w J der wi m q L sin phi es end Pendulum 1 4 Using the Modelica Standard Library In this example we will show how a model is built up using components from the Modelica Standard Library The task is to model a motor drive with an electric DC motor gearbox load and controller Motor drive built with Sonia standard components positionerror motor E load peojiud As when building a real system there are several approaches One extreme approach is to build the system from scratch However it is often a difficult and time consuming task An other approach is to investigate if the system already is available on the market or if there is some product that easily can be adapted or modified If not build the system from compo nents available when possible and develop only when necessary The idea of object oriented modeling is to support easy and flexible reuse of model knowledge Modelica ha
50. eature is that the component equations and the media models as well as pressure loss and heat transfer correlations are decoupled from each other e Media includes property models of media e Thermal provides models for heat transfer and thermo fluid pipe flow e Math gives access to mathematical functions such as sin cos and log and operations on matrices e g norm solve eig exp e ComplexMath contains complex mathematical functions e g sin cos and functions operating on complex vectors e Utilities contain functions especially for scripting operating on files streams strings and systems e Constants provide constants from mathematics machine dependent constants and con stants from nature e Icons provide common graphical layouts used in the Modelica Standard Library e Slunits with about 450 type definitions with units such as Angle Voltage and Inertia based on ISO 31 1992 To get documentation for the entire Modelica Standard Library place the cursor on Modeli ca right click and select Info An information browser is directed to an HTML file containing documentation for Modelica This documentation has been generated from the Modelica description of the library There 1s basic information such as the content of the library conventions and conditions for use Dymola comes also with other free model libraries A list of these libraries is given by the command File Libraries The package menu gives direct
51. ect Mode when the background is white it 1s in connect mode Click on Icon toolbar button to look at the icon layer You will see the icons for the connectors Let us draw an icon for the motor model One design is shown below The thicker line to the right symbolizes the physical axis from the motor It is a good idea to select that line and use the context menu Order Send to Back to prevent any case where the axis seems to be lying outside the motor The icon of the electri cal DC motor Toolbar for editing name To draw it we will use the toolbar for editing graphics DM D OQ ABZ amp n Z Start by drawing the big red cylinder shaded rectangle Click the Rectangle button yellow rectangle and draw a rectangle Let it be selected Click on the arrow to the right of the Fill style button Select Colors and then select a red color Click OK To select the gradient click once again on the arrow to the right of the Fill style button Select Gradient gt Horizontal Draw the rest of the parts using Rectangle or Polygon in an analogous way To enter the text click the Text button the button labeled A and lay out a rectangle that is as long as the cylinder and one grid squares high In the window prompt for the string enter name and click OK The sign has the magic function that when the model is used the actual component name will be displayed 1 4 4 Documenting the model We have now edited the icon and the di
52. ere are no components that can be dragged from this library to the edit window it is purely documentation This library 1s free Modelica Standard Library has been dealt with earlier in this chapter This library is free Model Management deals with version management model dependencies encryption model and library checking including regression testing of libraries model comparison and model structure It can not be used free it demands a license For more information please see the manual Dymola User Manual Volume 2 chapter Model Management Design deals with four main areas e Model calibration makes it possible to calibrate and assess models The Model Calibration option is required for problems with more than one tuner For more information please see the manual Dymola User Manual Volume 2 chapter Model calibration e Model experimentation gives the user possibility to vary parameters of the system to get an intuitive knowledge of the behavior of the model Monte Carlo analysis is 1 7 included This part of the library is free For more information please see the manual Dymola User Manual Volume 2 chapter Model Experimentation e Design optimization is used to determine improved values of model parameters by multi criteria optimization based on simulation runs The Optimization option 1s required if used on more complex models For more information please see the manual Dymola User Manual
53. estMotor DriveLib TestMotor Plot 1 y File Edit Simulation Plot Animation Commands Window Help amp iiloQev e smsu Hevo i amp mmBP ELI gt Wid 4D Tmel E Speed 1 Variable Browser motor flange b1 phi Variables Values 60 zi TestMotor 1 imotor xiRa x emf HVS step lt gt 2 true simulateModel DriveLib TestMotor method dassl resultFile TestMotor true lt Commands X Modeling V Simulation First we may establish that a positive input signal makes angular position increase The plot looks almost like a straight line However there are some wriggles in the beginning Zoom in use the mouse to stretch a rectangle over that portion of the curve you would like to see We may also plot the angular velocity motor Jm w there is an oscillation which dies out and the velocity becomes constant There is much to be done to validate the model However model validation is out of the scope for this introduction to Dymola It is possible to show several curves in the same diagram Simply tick the variables to be plotted A curve is erased by ticking once more The toolbar button Erase Curves white rectangle erases all curves in the active diagram It is also possible to have several diagrams To get a new diagram select Plot New Diagram or click on the toolbar button The new diagram becomes active Tick motor Jm w and the result shown below are
54. eter Modelica SIunits Mass Description Mass of pendulum Modelica parameter Modelica SIunits Mass m 1 Mass of pendulum Click OK and the text appearing in the bottom row is inserted into the Modelica text window The other quantities are defined in analogue ways When coming to the variables phi and w they are variables not parameters Nothing should be entered in the type prefix input field for those When completing the form to declare the angle phi the start value of the angle is defined by clicking on the small triangle to the right of the value field and selecting Edit A submenu pops up Enter 0 1 for start The result will look like Entering a start value Variable declaration in Pendulum General Model Path Modelica SIunits Angle Comment Parameters displayUnit min max start fixed nominal stateSelect Click OK The following result 1s displayed 30 The result model Pendulwumz parameter Modelica SIunits Mass m l Mass of the pendulum parameter HModelica SIunitz Length L l Lenght of the pendulum parameter Modelica SIunits Acceleration g 9 81 Gravity of acceleration parameter Modelica SIunits Moment flnertia J m L z Moment of inertia Modelica SIunits ngle phii start 0 1 Pendulum angle Modelica SIunits ngularVelocity w angular velocity equation der phi w J deriw m ug L zsiniphi j
55. g Dymola will itself take care of this but we will have warnings when translating In order to avoid these warnings phi start and w start should be set to fixed true using the menu above for all joints To get a double pendulum create another similar joint and another BodyBox and connect them This is accomplished easily by selecting the two components already present and choosing Edit Duplicate The selection of the start value type for phi start can be removed from R3 if wanted You should now have arrived at a model that 1s similar to the following The diagram of the Fu R2 B1 ruta pendulum r 0 5 0 0 4 lo s 0 0 o s 05 0 1 cg m Now it is time to simulate To enter the Simulation mode click on the tab at the bottom 4 Simulation right The simulation menu is now activated and new tool bar buttons appear all When building 3D mechanical models it is possible to get visual feedback to check that the mechanical system is put together as intended Click on the toolbar button Visualize The animation window shows the initial configuration of the system 76 Initial configuration of system Translate the model In the variable browser open R2 by clicking on the in front of it and enter a value for phi start say 1 rad and simulate for 5 seconds use the command Simulation gt Setup to change the stop time View the pendulum in the animation window you may want to adjust the perspecti
56. he continuous states phifstart 0 1 Assuming Fixed default start value For the continuous states wistart D Warning The initial conditions are not Fully specified Dymola has selected default initial conditions LogDefaultInitialConditions true gives more information In order to have sufficient number of initial conditions Dymola look at the possibility to use variables as states and attribute fixed start values to such states For more information please see chapter Introduction to Modelica section Initialization of models and more advanced the manual Dymola User Manual Volume 2 chapter Advanced Modelica support section Means to control the selection of states Dymola presents in the warnings what variables have been selected as states with fixed start values Dymola assumes fixed start values phi 0 1 and w 0 We have set the start value of phi to 0 1 above while the start value of w was implicitly given a start value of zero default However the attribute fixed is the problem Fixed true means that the start value 1s used to initialize the model it must be satisfied during initialization Fixed false means that the value is just a guess value for a non linear solver For variables fixed is default false Since the intention was to use these variable values as initialization values the best is to explicitly set the fixed attribute to true and also explicitly specify the start valu
57. hi step y 1 2 ziMotorDriveT est 2 4 positionerror controller motor gearbox load ziphiload flange v phi limiter Estep height iv y offset startTime K gt Modeling V Simulation Handling the warnings There will be some warnings when translating The principal handling of these warning has been dealt with previously The only thing that ought to be mentioned here is that in order to make the variable controller D x start controller D x start fixed you have to double click on the MotorDrive then select the controller right click and select Show component Now you can double click on the D component to see the parameter dialog and since no x 1s available you have to select the Add modifier tab enter x ixed true and press OK The rest of the warnings can be handled like described in a previous section 1 4 8 Parameter expressions Modelica supports parameter propagation and parameter expressions which means that a parameter can be expressed in terms of others Assume that the load is a homogeneous cyl inder rotating long its axis and we would to have its mass m and radius r as primary pa rameters on the top level The inertia is J 0 5 m r 2 We need to declare m and r in MotorDrive Open MotorDrive Activate the Modelica Text representation press the Modelica Text toolbar button the second rightmost tool button Declaration of parameter
58. itor Pendulum Pendulum Modelica Text PES File Edit Commands Window Help x SHAS NM NOOVAms amp Z h gt SABE om Package Browser Bx model Pendulum Packages equation Modelica Reference Modelica end Pendulum Unnamed Component Browser mx Components To declare the parameters and the variables enter as shown the declarations for the parame ters m L and g which also are given default values The parameter J is bound in terms of other parameters Finally the time varying variables phi and w are declared A start value is given for phi while w is implicitly given a start value of zero model Pendulum parameter Real m 1 parameter Real L 1 parameter Real g 9 81 parameter Real J m L 2 GETTING STARTED WITH DYMOLA 21 Real phi start 0 1 Real w equation der phi w J deriw m g L sin phi end Pendulum New text will be syntax highlighted color coded as you type except types e g Real To get also types color coded right click and select Highlight Syntax or press Ctrl L Apart from implementing color codes for types the command will also give a message if the syntax is not correct It is a good idea to use the command regularly The command does not however change the formatting of the text tabs etc Such change is implemented by selecting the part of the text that should be reformatted and then right clicking and selecting Reformat Selection or press Ct
59. kages are write protected It is also possible to use the drag and drop feature and drag DriveLib into the slot In the package browser put the cursor on DriveLib and press the left mouse button While keeping it pressed drag the cursor to the slot for Insert in package optional release the button and the text DriveLib will appear in the slot It is also possible to browse for a package where to insert the model clicking on the browser symbol to the right Create New Model Name of new model Description PO Partial Extends taptianal E O B Insert in package optional Click OK The package browser shows that DriveLib has a component Motor as desired The picture below shows the model with the diagram layer displayed compare with the package created above GETTING STARTED WITH DYMOLA 45 An empty Motor model 46 Motor DriveLib Motor Diagram SEE 8 x pu File Edit Commands Window Help Haa M NDOQ A 2 ih Z e mEPEHSE Package Browser mx Packages H Fluid Media J Thermal math utilities fa Constants j gy Icons Sunis Unnamed fF DriveLib A Component Browser Components DriveLib Motor The model window now contains an empty Motor model The edit window has a gray frame and grid to indicate that the component is not write protected It is possible to toggle the grid using the toolbar button
60. laying any menu help for a certain entry is available by resting the cursor on it and then pressing Shift F1 Tooltips By resting the cursor on any component or button a tooltip text is shown For buttons it will be the name of the button for components it will be the name of the component the path to it The Search command button The search functionality can be reached either using the command File gt Search or clicking the Search button See chapter Developing a model section Editor command reference Modeling mode sub section Main window File menu command File gt Search for more information 1 7 2 Reaching more extensive information The Info command button If any component is selected in the Edit window or in the package or component browser right clicking will take up a context menu where the command Info is available Inside a dialog a button Info is available instead The Help menu The Help menu can be used to display manuals and to go to the Dymola website The help menu also contains the license handling The help menu is described in chapter Developing a model section Editor command reference Modeling mode sub section Main window Help menu The Search command button The search functionality can be reached either using the command File gt Search or clicking the Search button For reference please see the corresponding section above The documentation layer of Edit window
61. ld a model of the Furuta pendulum To build the Furuta pendulum you will need to use the Parts and Joints sub packages If you open them in library windows by right clicking on them in the package browser and using the command Open Library Window and adapting the window they will look the following Parts package Madelica Mechanics MultiBady Parts PREIES Fixed FixedTranslation FixedRatatian Bodyshape BodyBox Body Cylinder e m d ob Pointhlass Mountingi D RatariD Bevelaear1D RollingWwheel Ralingwheelset GETTING STARTED WITH DYMOLA 13 The Joints sub package library window 74 Joints package Modelica Mechanics MultiBady Joints Em s 4h Revolube RevolubePlanarLa Cylindrical Universal Planar XQ M d xls Spherical FreeMotion Spherical5pherical UniversalSpherical GearConstraint Rolling heel Mad av Rolling Wwheelset Assemblies Internal Select File gt New gt Model and give the name Furuta The first step in building a MBS MultiBody System model is to define an inertial system Drag the component World from the package browser Multibody package into the Furuta edit window The default parameters need not be changed The gravity of acceleration is set to 9 81 and pointing in the negative direction of the y axis We then need a revolute joint Drag the model Joints Revolute onto the Furuta window You can either drag from the package browser or the library window Select E
62. meters can be further structured into groups as shown It is easy for a model developer to customize the parameter dialogs More information about customization can be found in the chapter Developing a model section Advanced model editing sub section Parameters variables and constants Graphical illustrations can be included to show meaning of parameters If prepared for display units can be selected in the dialog Units that have alternatives are marked by white background here phi start and w start have selectable display units By resting the cursor over such a unit a button 1s displayed Selectable display unit Initialization phistart o 0 0p Relative rotation angle from frame a ta frame b wastat i rads irit derivative of angle phi relative angular velocity Select display unit ive of angle phi relative angular acceleration and by clicking on that the selection can be made 10 Alternatives of selectable display unit ii Edit Edit Text Copy Default R view Parameter Settings Insert Component Reference gt Insert Function Call so a Choices for n Initialization phistat i PER elative rotation angle fram frame a to frame b wastat i deg rat derivative of angle phi relative angular velocity astat i rad s Second derivative of angle phi relative angular acceleration Next to each parameter field is a triangle this gives you a set of choices for editing the p
63. n by the package browser the Modelica Standard Library includes e Blocks with continuous and discrete input output blocks such as transfer functions filters and sources e ComplexBlocks provides basic input output control blocks with complex signals This library is especially useful eg in combination with the library Modelica Electrical QuasiStationary in order to build up very fast simulations of electrical circuits with periodic currents and voltages e StateGraph for modeling of discrete events and reactive systems by heretical state machines Please note that a more advanced library is available using the command File gt Libraries gt State Graph For more information about this library please see section Libraries available in the File menu by default starting on page 78 e Electrical provides electric and electronic components for analog digital machines and multi phase models such as resistor diode DC motor MOS and BJT transistor e Magnetic contains magnetic components to build especially electro magnetic devices GETTING STARTED WITH DYMOLA 35 36 e Mechanics includes one dimensional and 3 dimensional translational rotational and multi body components such as inertia gearbox planetary gear bearing friction and clutch e Fluid contains components to model 1 dimensional thermo fluid flow in network of vessels pipes fluid machines valves and fittings All media from Modelica Media can be used A unique f
64. nals to the controller and control signals from the controller to the actuator The bus for one axis has the following signals GETTING STARTED WITH DYMOLA 13 The robot controller in the robot drive train controller 14 Name Description motion_ref true if reference motion is not in rest angle ref reference angle of axis flange angle angle of axis flange Speed ref reference speed of axis flange Speed Speed of axis flange acceleration ref reference acceleration of axis flange acceleration acceleration of axis flange current ref reference current of motor current current of motor motorAngle angle of motor flange motorSpeed Speed of motor flange The bus from the path planning module is built as an array having 6 elements of the bus for an axis The figure below is displayed by selecting the controller and showing the components of it gain axiscarmtralBus The controller of an axis gets references for the angular position and speed from the path planning module as well as measurements of the actual values of them The controller out puts a reference for the current of the motor which drives the gearbox The motor model consists of the electromotorical force three operational amplifiers resis tors inductors and sensors for the feedback loop The robot motor motor i T ni n e c Rd c Rpt T j E iz R 100 cho oo vpi y R 200 A dit power 5 cea m t i Gd Jmator flange On
65. nd the name of the variable e Conclude with a semicolon e Use Edit gt Variables and select the new variable Handling of warnings When simulating we still get a warning that the initial conditions are not fully specified By clicking on the Translation tab in the Messages window and scroll to the top the following can be seen GETTING STARTED WITH DYMOLA 31 32 Messages Dymola SSS E Syntax Error Translation Dialog Error Simulation Version Management Translation of Pendulum The DAE has 2 scalar unknowns and 2 scalar equations Warning The initial conditions are not Fully specified Dymola has selected default initial conditions LogDefaultInitialConditions true gives more information STATISTICS Original Model Number of components 1 Variables 6 Parameters 4 4 scalars Unknowns 2 2 scalars To get more information select Simulation gt Setup or click directly on the Experiment Setup toolbar button click on the Translation tab and check Log selected default initial conditions Simulating yet another time and checking the Translation tab of the Messages window will yield Messages Dymola ig z Eg E CTT Syntax Error Translation Dialog Error Simulation Version Management Translation of Pendulum The DAE has 2 scalar unknowns and 2 scalar equations Warning The initial conditions For variables of type Real are not Fully specified Assuming Fixed start value For E
66. nds X BB Modeling V Simulation Let us study a swing pendulum with larger amplitude and let it start in almost the top posi tion with phi 3 It is easy to change initial conditions Just enter 3 in the value box for phi and click on the Simulate tool button You can also change start values and parameters by typing in the commands window e g type phi 3 followed by carriage return for a change of phi GETTING STARTED WITH DYMOLA 25 Pendulum angle when starting in almost the top position 26 Pendulum Pendulum Plot y File Edit Simulation Plot Animation Commands Window Help duae Mie Boon Bevott SSmR Boe bM M 4I rne E Speed 1 v Variable Browser x phi Variables Values i Pendulum 1 e Pendulum 2 CIm PIL dg CJ v phi der phi jw C der w lt gt phi 3 plot I phi 1 simulateModel Pendulum stopTime 10 method dassl resultFile Pendulum x true b B Modeling V Simulation The results of previous simulations are available as the experiment Pendulum 1 in the Variable browser We can open it up and have phi of the two runs plotted in the same diagram by expanding Pendulum 1 in the variable browser and check the checkbox for phi ommands Results from two Pendulum Pendulum Plot simulations File Edit Simulation Plot Animation Commands Window Help fer QOS M emo
67. nknowns and equations 2 Check of Pendulum successful The model is now ready to be saved Select File gt Save Call the file pendulum and keep the file extension to mo and place it in a working directory 1 3 1 Simulation Now it is time to simulate To enter the simulation mode click on the tab Simulation at the bottom right of the main window The simulation menu is now activated and new tool bar buttons appear To set up the simulation select Simulation gt Setup or click directly on the Experiment Setup toolbar button Pendulum Pendulum File Edit Eaa Plot Animation Comr E Li EM Bur Script x Custo iP dI d Translate id Time 0 uiis Simulate E Variables Continue Jt Descriptio e Stop Linearize u E Visualize Show Log GETTING STARTED WITH DYMOLA 23 The Simulation Setup Experiment Setup CORTE menu Genera Translation Output Debug Compiler Realtime Experiment Name Pendulum Simulation interval Start time 0 l Stop time n Dutput interval Interval length 0 Number of intervals 500 Integration Algorithm Dassl Tolerance 0 0001 Fixed Integrator Step ID Set the Stop time to 10 seconds Click OK M To run the simulation select Simulation gt Simulate or click directly on the Simulate toolbar button Selecting Simulate in Pendulum Pendulum the Simulation menu File Edit Beni Plot Animation Comm Run Script
68. nteresting component right click on it and select Show Variables which will open and highlight the selected component instance in the variable browser In the figure below the variables of the motor in Axis 1 is displayed in this way 18 fullRobot Modelica Mechanics MultiBody Examples Systems RobotR3 fullRobot Using the diagram File Edit Simulation Plot Animation Commands Window Help layer to select ime QOS vem BEevo i PiRSh AUH WM A aD Dp Time X zw Plot 1 ox variables to be shown controlBus axisControlBus3 speed ref rad s controlBus axisControlBus3 speed rad s gt lw Diagram w max 315 rac amp flange motor Vs diff H power emf La Ra Animation Rd2 C Opl Rd HRI Rpt Rp2 Rd4 hall2 Rd3 wgl tHa2 i93 hall Had 95 phi speed ki Jmotor fi converti convert2 axisControlBus controller w i il gt animationRedraw AS true d true M a lt motor gear Seam 1 peo giouo sixe sn zo 3 Ee Bala initializeFl modeling Y Simulation Please note that if the diagram layer window is active selecting another component in the variable browser will also change the selection in the diagram layer window 1 2 2 Other demo examples Other demo examples can be found under the File Demos menu After selecting an exam
69. on Comman ds Window eip ot Help aude NT UUDoCASEZ 5 Th Zi gt BEB BS ox Package Browser a 8 x model Pendulum Packages 1 1 equation i rAttenuationCoefficient der phi v PhaseCoefficient J deriw n g L siniphi PropagationCoefficient Damping Mass Density Dymola RelativeDensiby Specificvolume LinearDensity SurfaceDensiby Momentum Impulse Angular Momentum Add component AngularImpulse Add class parameter Pod r MomentOfInertia replaceable type meme Inertia ooo Modelica SIunits Mass EEE L Add base class Component Browser end Pendulum Dropped class Modelica SIunits Mass Actions Change class of component Components The choice to add a component is pre selected Click OK A menu to declare a variable pops up Declaring a variable Sena AEE Declaration Type Prefix Annotations Type and name v Modelica SIunits Mass Description Modelica Modelica SIunits Mass Now we can specify the type prefix parameter the name value and description By keeping the cursor on top of an input field for a while a tooltip text pops up explaining the field Complete the description in the following way GETTING STARTED WITH DYMOLA 29 Declare variable Declaration Type Prefix Annotations Type and name param
70. on of how to access model components and documentation of a library we will continue by actually building a model for an electric DC motor This task will give us more experience 1 4 2 Creating a library for components It is a good idea to insert developed components into a library It is a good way to keep track of components and it supports also the drag and drop feature when you will use the models as components Let us collect all developed components in a library called DriveLib Go to the Dymola window and select File New Package This will pop the dialog 42 Creating a new Modeli ca package Create New Package Mame of new package Description Pd Partial Extends optional PO Insert in package optional Save contents of package in ane file Enter DriveLib as the new name of the package and click OK and Accept in the informa tion window A package DriveLib is created and made visible in the package browser if scrolled Select Modelica text to get the Modelica representation which at this stage just specifies a package with no contents The layer shown in the package created Modelica Text layer Diagram layer etc depends on what layer was shown when creating the package From the result below it is obvious that the Modelica Text layer was shown when this package was created The layer shown can easily be changed by buttons in the toolbar in the upper right of the window GETTING STAR
71. ose in the parameter dialog to leave it If you want to see the documentation without going via the parameter dialog right click on the component in the diagram and select Info Let us now inspect the drive train model There are several possible ways to get it displayed Press the Previous button the toolbar button with the bold left arrow once to go to the robot model and then put the cursor on one of the axis icons and right click Please note that robot mechanics also has components axisl1 axis6 but those are just connectors You must inspect for example robot axisl see figure below GETTING STARTED WITH DYMOLA 11 Displaying the fullRobot Modelica Mechanics MultiBody Examples Systems RobotR3 fullRobot Diagram components of axis 1 a2 File Edit Simulation Plot Animation Commands Window Help I6 X iude YENDO AN SB TN Zin gt PERE Sox v Package Browser x Packages mp UU c User s Guide of MultiBody Libr ii woid Examples 7 Elementary 3 Loops E C Rotational3DEffects pathPlanning axisControlBus6 B Mj Systems i mechanics zi T RobotR3 m oneAxis jus Jv HEI gt CK Component Browser controlBus Components 5 axisControlBus1 Parameters m k Show Component Open Class in New Window Attributes ia Change class t EH Ee EH EH be EH ee it H pathPlanning axis Info Edit annotation
72. ow translated and simulated automatically The script also contains some setting of a plot window and an animation window After maximizing the Dymola main window it will look the following fullRobot Modelica Mechanics MultiBody Examples Systems RobotR3 fullRobot ES File Edit Simulation Plot Animation Commands Window Help ime QOS Me Bio Beyren Gm mRHP Aie M Maa p gt Timeo Sped 1 v OX Variables Values es DEK CHulRobotl controlBus axisControlBus3 speed_ret rad s controlBus axisControlBus3 speed rad s mLoad 15k LIrLoad 1 r I rLoad 2 r C rLoad 3 r o 9 81 r refStartTime s refSwingTime 05s start nglel 60 c O startAngle2 20 c startAngle3 90 c start ngle4 Olc start amp ngle5 0c O start ngle6 Ole end amp nglel 60 c O end ngle2 70 ic O end ngle3 35 c O end ngle4 45 c end ngle5 110 c end amp ngleS 45 c refSpeedMas 1 3i nmn refSpeedMas 2 15l Animation refSpeedMax 3 Sir refSpeedMas 4 31r _ refSpeedM ax 5 3 1 jr refSpeedMax 6 4 1 r ref amp ccMas 1 15ir ref amp ccMax 2 15i ref amp ccMas 3 15 r ref ccMas 4 60 r J refAccM ax 5 60 r ref amp ccMax 5 60 r L kpi 5 L kst 0 5 L Tsl 0 05 s L kp2 5 L ks2 0 5 LITs2 0 05 s L kp3 5 L ks3 0 5 L Ts3 0 05 s L kp4 5 L ks4 0 5 L Ts4 0 05 s Okps 5 v lt JI gt
73. ple it can be simulated by running a corresponding script file as was done for the robot ex ample The exception is the demos in Automotive Demos Library It contains several demos and the relevant demo has to be opened first by expanding the package Examples in the package browser by clicking the before it and then double clicking on the relevant demo to open it Please note that to run any of the Automotive Library demos you have to have a number of licenses for commercial libraries Please see the description presented when opening the library for more information GETTING STARTED WITH DYMOLA 19 1 3 A pendulum The first step to create a new model 20 Solving a non linear differential equation This example will show how to define a simple model given by an ordinary differential equation We will simulate a planar mathematical pendulum as shown in the figure Le phi mg The variable m is the mass and L is the distance from the support to the center of mass Let us assume the string is inextensible and massless and further let us neglect the resistance of the air and assume the gravitational field to be constant with g as the acceleration of gravity The equation of motion for the pendulum is given by the torque balance around the origin as J der w m g L sin phi where J is the moment of inertia with respect to the origin Assuming a point mass gives J m L 2 The variable w is the angular velocity and der
74. rl Shift L The color codes are black values variables parameters etc green comments If the text seems too small to work with the text size can be changed using the Edit gt Options command and temporary changing the Base font size in the Appearance tab It is a good idea to set it back afterwards Declaration of parame Pendulum Pendulum Modelica Text Editing Sle ters variables and EH File Edit Commands Window Help E X equations ms e vum aN Seg m A q SUREN NOOA 5 HZ elna Package Browser x model Pendulum Packages parameter Real m 1 Madelica Ref parameter Real L 1 10 UC IST ROS parameter Real g 9 81 J Modelica parameter Real J m L Z Unnamed Real phi start 0 1 equation der phi w J der w m g L siniphi end Pendulum Since the model should be simulated it should be checked before saved The check command performs some symbolic and syntactic checks that will capture a number of errors that might have been introduced by the user The check can be made clicking on the Check icon or by selecting the command Edit Check or by using the F8 function key The result of a check of the above text looks the following 22 Check of model Modeling 2 Simulation KH m Selecting Setup in the Simulation menu Messages Dymola Syntax Error Translation Dialog Error Simulation Version Management Check of Pendulum The model has the same number of u
75. rowser mx PP od P Poxz eHeatingResisk PP eaung ess O Resistor Ideal linear electrical resistor Pili Conductor You can also drag from a library window Drag a resistor from Basic to the Motor window and place it as shown above The compo nent browser displays that Motor has a component Resistor1 GETTING STARTED WITH DYMOLA 47 Inserting a resistor component The parameter dialog of a resistor with de fault settings 48 Motor DriveLib Motor Diagram Ix File Edit Commands Window Help SHIS NYNO AR 2 HN Z Ve BEEZ om aat Package Browser mx Packages P i i ibo a iP P ROT Ground resistor iil ta R R PP P P pxzRHeatingResistor a When inserting a component it is given an automatically generated name The name may be changed in the parameter dialog The class name begins with an upper case character component instances begins with a lower case character Double click on the component to get its parameter dialog The parameter dialog can also be reached by placing the cursor on the component right clicking and selecting Parameters resistor in DriveLib Motor General Add modifiers Component Model Resistor Path Modelica Electrical 4nalog Basic Resistor Comment Ideal linear electrical resistor Parameters R Resistance R ref at temperature T ref T ref 27 Reference temperature Temperature coefficient of resistance R_actual
76. s been designed to support reuse of model components as parts in different models and to support easy adaptation of model components to make them describe similar physical components The design of Modelica has also been accompanied by the development of model libraries GETTING STARTED WITH DYMOLA 33 Opening the Modelica Standard Library 34 1 4 1 The Modelica Standard Library We will now have a look at the Modelica Standard Library to see what is available and how we access the model components and their documentation To open the library double click on Modelica in the Package browser Dymola Dynamic Modeling Laboratory Diagram I A File Edit Commands Window Help SHa RY NDOO ARN amp iA Package Browser Packages Modelica Reference E fa Modelica Modelica lt Nok yet opened gt Dymola reads in the library The Modelica Standard Library is hierarchically structured into sub libraries The sub libraries of the Modelica Standard Library Dymola Dynamic Modeling Laboratory Diag E File Edit Commands seHaS i WievoOovAn LZ Package Browser Bx Packages Modelica Reference f Modelica users Guide e Blacks e Complexlocks fig StateGraph e Electrical e Magnetic I Mechanics Fluid Media Thermal nat amp omptexmath m tities constants icons Stunits As show
77. s lt b gt and i 8 lt b gt images lt fb gt of this editor lt b gt c b n image of the toolbar above i utiities illustrates the image possiblility lt p gt H Z Constants lt p gt lt img src modelica DriveLib Images toolbar png p i lt p gt For more information about this editor please see chapter s gilicens amp QUOT Developing a model amp QUOT in this manual lt p gt amp J Slunits lt p gt More information about Dymola in general is found in lt a Unnamed href http jnr Dymola com ins Dymola com lt fa gt lt fp gt zfhtml amp privetib i a By right clicking and selecting Show gt Formatted documentation the result will be shown GETTING STARTED WITH DYMOLA 53 The final result Checking the model 54 Motor DriveLib Motor Documentation BEES 8 X I File Edit Commands Window Help GBHGeNuDnocAM amp Z W e mBHHS o Package Browser 8 X A basic model of an electrical motor Sayre Information amp utilities This is a simple motor model E f constants This documentation can certainly be extended using e g links and images of this editor An image of the Scons toolbar above illustrates the image possiblility d Stuits Text style Normal S s e n m Se me 2 co EES Unnamed E briveLib For more information about this editor please see chapter Developing a model
78. simulate it and look at the results If you want to learn the basics first you can skip to a smaller example in the next section 1 3 Solving a non linear differential equation on page 20 We will study a model of an industrial robot To view the industrial robot model use the File gt Demos menu and select Robot Opening a demo exam Dymola Dynamic Modeling Laboratory Diagram ple Edit Simulation Plat Animation Commands Window Help New ev AE ijn s Ta Open Cro pneum Libraries save CtrH 5 Motor Drive Save 45 Furuta pendulum Save All Coupled clutches Save Total Automotive Demos Library Version ul Dymola starts loading the model libraries needed for the robot model and displays it The following will be displayed The robot demo fullRobot Modelica Mechanics MultiBody Examples Systems RobotR3 fullRobot Diagram File Edit Simulation Plot Animation Commands Window Help J x DOeNMuuoogAMI S5 Hh sz 383 EHE v Package Browser 1 Packages FE SAISIR ee c User s Guide of MultiBody Libr ii weld J Examples 7 Elementary t _ Loops Rotational3DE ffects pathPlanning axisControlBus6 zi Systems mechanics J RobotR3 oneAxis Li JL Jj Lew Component Browser x controlBus Components mechanics pathPlanning
79. stems Sizes of nonlinear systems of equations Sizes after manipulation of Ehe nonlinear systems Number of numerical Jacobians 0 Warning The Following parameters don t have any value only a start value motor emf kistart 1 Finished WARMING 3 warnings were issued Finished Two types of warnings are present for this example a warning that initial conditions are not fully specified at the top of the tab and a warning that a parameter does not have any value only a start value at the bottom of the tab The first type of warning has been described previously see section Handling of warnings on page 31 The difference here is that we can use the graphical user interface to set the variables to fixed we do not have to enter code Looking at the warnings they all have to do with components inside the Motor model By double clicking on the Motor in the package browser we return to this model The two first warnings in this part have to do with the inertia Jm Double clicking on this component brings up the parameter dialog for it and in the Initialization section phi and w are found By clicking on the little square in front of each of these variables a menu pops where we can select fixed true The final result will be Jm in DriveLib Motor General Advanced Add modifiers Component Model Path Modelica Mechanics Rotational Components Inertia Comment 1D rotational component with inertia Par
80. stor break the line by clicking at an intermediate point There is a possibility to obtain automatic Manhattanize of connections non endpoints of the connections are moved to make all line segments horizontal or vertical Select the connection right click and select Edit Manhattanize Draw all connections Note that we could have drawn a connection between two components as soon as we have the components and we have not to wait until all model components are in place The points of the connectors can be moved and new points can be inserted using the context menu of the connector Finally we have to introduce a signal connector for the voltage control and a flange connec tor corresponding to the shaft of the motor so the motor can be connected to an environment We would like to place the icon of the connectors at the border of the grid of the drawing pane because the icon of a model component also includes the connectors The connector inPort must be compatible with the connector of Vs inPort There is a simple way to get a connector inPort that is a clone of Vs inPort Start drawing a connection from Vs inPort and go to the left until you reach the border of the grid Then you double click and select Create Connector from the menu popped up The connector flange b is created in a similar way If you would like to adjust the position of a connector it 1s easy to get into connect mode This can be avoided by toggling the toolbar button Toggle Conn
81. t O emt m 1 Je Iud s paads Conve C a cE s k k hall2 conve axis Controlbus View the component gear in a similar way as for the other components It shows the gearbox and the model of friction of the bearings and elasticity of the shafts The robot gearbox l flange of joint axis gear flange of motor axis bearingFriction Bear 1 1 flange a d flange b rat i 1 2 1 Simulation Let us simulate the robot model To enter the Simulation mode click on the tab Simulation at the bottom right of the main window Please note that selecting Simulation mode is not the same as simulating the robot it however gives the possibility doing so the needed menus are available in this mode Modeling 2 Simulation GETTING STARTED WITH DYMOLA 15 Simulating the demo by running a script Animated 3D view of the robot 16 The Simulation menu contains commands to setup and run simulations Shortcut buttons are also available However the demo has also been prepared with a command script that will simulate the model The script is executed selecting Commands Simulate Please use that command fullRobot Madelica Mechanics MultiBady Examples Systen File Edit Simulation Plot Animation Emme gc window Help y b T H 4I I gt Ti Plot result of axis 3 animate Add command Organize Commands H Variable Browser Variables Values The model is n
82. t solved creating a function that can be included in other models Creating functions is not treated here please see chapter Simulating a model in the manual for more about scripting in particular using functions If the simple example here should be saved as a script file the easiest way is to do the following assuming that the models have been saved 1 Go to Modeling mode clear everything using the command File gt Clear All Clear the content of the command log pane using the command File gt Clear Log Reopen the DriveLib package using File Recent Files Open MotorDriveTest and simulate it Set wanted values of controller Simulate again Force a plot command like in previous section pb lE e i come X Save the command log using File Save Log Select saving it as a mos file by selecting that alternative in the Save as type input field Give it a name e g MyScript The saved script can be opened and edited using a text editor e g Microsoft Notepad GETTING STARTED WITH DYMOLA 71 P MyScript mos Notepad File Edit Format View Help L Script generated by Dymola Tue Oct 27 12 06 16 2009 simulateModel DpriveLib MotorDriveTest stopTime 5 method dass1 resultrFile MotorDriveTest controller k 15 controller Ti 1000 controller Td 0 4 simulateModel DriveLib MotorDriveTest stopTime 5 method dassl resultFiles MotorDriveTest plotc phiload phi step y j Note the
83. the PID controller could be GETTING STARTED WITH DYMOLA 69 An example of MotorDrive lest DriveLib MotorDrive Test documenting File Edt Simulation Plot Animation Commands Window Help simulation SEAS Nieo Be ven o FER BOE S gt D gt UW ld X 4l ib Time o 1 Speed 1 uj Variables Yalues Unil phiload phi iMotorDriveTest 1 MotorDriveTest 2 Hgearbox phiload motor load Hpositionerror icontroller rOy lt X Text style Heading 1 ib i u ce HN n T M a X a XP uma i Selecting better values than the original ones for the PID controller k 15 controller Ti 1000 controller Td 0 4 simulateModel DriveLib MotorDriveTest stopTime 5 method dassl result File MotorDriveTest true i deselecting and selecting step y and then clicking on the command input line to force a plot to be included in the command log pane plot I phiload phi step y 1 phiload phi step y 1 2 1 0 0 8 0 6 0 4 0 2 0 0 0 2 0 0 25 5 0 Note The overshoot is now to big but that is because the limiter component is not yet included Commands Modeling V Simulation Some comments e This example is just a minor example of what can be done More about using the command log pane to document simulations can be read in chapter Simulating a mo
84. the plot window The plot shows the speed reference and actual speed of the third joint A very convenient way to display the variables for a certain component that is of interest is to use the diagram layer of the edit window also in Simulation mode The diagram layer enables the user to follow a simulation by displaying variables and to control it by setting parameters The user can descend into any level of the model in order to plot or display variables GETTING STARTED WITH DYMOLA 17 Blin Push the Diagram layer button in the diagram layer toolbar to show the diagram The mm result might look like The diagram layer in fullRobot Modelica Mechanics MultiBody Examples Systems RobotR3 fullRobot Si File Edit Simulation Plot Animation Commands Window Help imulation mode ES M mu Blevoi FER DOH gt M M AA I yp tine e Browser x J Plot 1 Variables Y Values Us SjfullRobot 1 controlBus axisControlBus3 speed_ref rad s controlBus axisControlBus3 speed rad s mLoad 15 kg LI rLoad 1 m I rLoad 2 m I rLoad 3 m a 9 81 m refStartTime s refSwingTime 0 5 s start nglel 60 de start ngle2 20 de start amp ngle3 90 de start ngle4 0 de Diagram start ngle5 110 de start ngle6 D d
85. the text and delete them Do not delete the equation that one we will keep The result will be Pendulum Pendulum Modelica Text Editing E File X Edit Commands Window Help SEQSNIVNOOVABY amp th 2 40 ae Package Browser model Pendulum Packages H equation 4 Modelica Reference be heh usan E Medelica J der w nm g L zsiniphil LInnamed end Pendulum Pendulum Open Modelica SIunits in the package browser by first expanding the Modelica package by clicking on the in front of it and then expanding SIunits by clicking on the in front of it Now a number of physical types should be visible What is to be done is to redo the declaration part of the model presented on page 21 using the physical types available in Modelica SIunits The mass is the first one to be declared To find Mass in the package browser click on the package SIunits to get a good starting point and then press m on the keyboard The first physical type starting with m will be displayed Pressing m again will find the next physical type starting with m and so on Another way to find it fast 1s by clicking on the header Packages of the package browser that will sort the physical types in alphabetical order Once Mass is found drag it to the component browser The following menu will pop up Adding a physical type Pendulum Pendulum Modelica Text z E File Edit Simulation P Animati
86. ve when working with the robot please see section Simulation on page 15 for tools used It will be nicer to present it by e g moving it to the following position Initial configuration of P system rotated around y axis The representation of the revolute joints as cylinders can be changed using the parameter animation if that is set to false the joint cylinders are not shown Change parameters and study the different behavior GETTING STARTED WITH DYMOLA 117 1 6 Libraries available when no optional library is installed 78 Try to control the pendulum in such a way as to get a stable upright position A trick is to use a mechanical PD controller i e a spring and damper attached to the tip of the second bar and to a high position Other libraries 1 6 1 Libraries available in the File menu by default Using the command File gt Libraries in a Dymola program with no extra libraries installed will at present display the following Dymola Dynamic Modeling Laboratory Diagram I A File Edit Commands Window ges Do Ams B E pa Ga Open CO mx pa Lbrades Modelica Reference i Demos d Modelica Standard Library Model Management 4 Save As Design Save All Plat 3D Save Total Modelica_LinearSystenms version d Modelica_StateGraphz Clear All WehicleInterfaces Modelica Reference is the documentation of classes operators etc from the Modelica Language Specification Th
87. w denotes the time derivative of w 1 e the angular acceleration For the angular position we have der phi w Start Dymola or if it 1s already started then give the command File gt Clear All in the Dymola main window Click on the tab Modeling at the bottom right Then select File gt New Model Dymola Dynamic Modeling Laboratory Diagram Edit Simulation Plot Animation Commands Window Help E tedel S Ha lar Open ceo connector Libraries 3 Record gq Demos Block amp save Cres Function i Save AS Package Save All Duplicate Class Save Total M A dialog window opens Enter Pendulum as the name of the model The dialog to name a new model component The model presented in the Modelica text layer Create New Model Mame of new model Description OOO Partial Extends optional N Insert in package optional Click OK You will then have to Accept that you want to add this at the top level You should in general store your models into packages as will be described later A model can be inspected and edited in different views When specifying a behavior directly in terms of equations it is most convenient to work with the model as the Modelica Text that is working in the Modelica text layer of the edit window To display this layer press the Modelica Text toolbar button the second rightmost tool button The edit window can now be used as a text ed
88. ymola For detailed information about the program you are referred to the on line documentation and the user s manuals The on line documentation is available in the menu Help Documentation The tool tips and the What s this features are fast and convenient ways to access information Please see section Help and information on page 79 for more information Start Dymola The main Dymola window appears A Dymola main window operates in one of the two modes e Modeling for finding browsing and composing models and model components e Simulation for making experiments on the model plotting results and animating behav ior Dymola starts in Modeling mode The active mode is selected by clicking on the tabs in the bottom right corner of the Dymola window The operations tool buttons available and types of sub windows appearing depend on the mode and the user s choice Dymola starts with a useful default configuration but allows customizing GETTING STARTED WITH DYMOLA 5 Dymola main e Dymola Dynamic Modeling Laboratory Diagram IE File Edit imulation Plot Animation Commands Window window m SHQ NY mopy AEZ 9h Z ih e y 88H B f 10 Package Browser Packages st Modelica Reference M Modelica Package browser Le J Eje Component Browser O Component browser a Modeling W Simulation 1 2 Simulating a model industrial robot This first example will show how to browse an existing model

Download Pdf Manuals

image

Related Search

Related Contents

EX762 - Optoma  Samsung HT-Z320T home cinema system  Samsung Dahili hoparlöre sahip 22" TV Monitör Kullanıcı Klavuzu  3 Year Guarantee Register online within 30 days* Terms  RapidTrace ® + User Manual  iMX233-OLinuXino-MICRO  Guía de seguridad del espectrómetro  ARCTIC COMPACT AGITATION SERIES MODELS: 8/1 - 8/2 - 8/3  

Copyright © All rights reserved.
Failed to retrieve file