simmechanics, maplesim and dymola: a first look on three

72
SimMechanics, MapleSim and Dymola: a first look on three multibody packages J.J.P. van Boekel DCT 2009.060 Bachelor Final Project report Coach(es): dr. ir. I.J.M. Besselink Supervisor: prof. dr. H. Nijmeijer Technische Universiteit Eindhoven Department Mechanical Engineering Dynamics and Control Technology Group Eindhoven, June 2009

Upload: trinhthuan

Post on 09-Feb-2017

224 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: SimMechanics, MapleSim and Dymola: a first look on three

SimMechanics, MapleSimand Dymola: a first look onthree multibody packages

J.J.P. van Boekel

DCT 2009.060

Bachelor Final Project report

Coach(es): dr. ir. I.J.M. Besselink

Supervisor: prof. dr. H. Nijmeijer

Technische Universiteit EindhovenDepartment Mechanical EngineeringDynamics and Control Technology Group

Eindhoven, June 2009

Page 2: SimMechanics, MapleSim and Dymola: a first look on three
Page 3: SimMechanics, MapleSim and Dymola: a first look on three

Contents

Abstract 4

Introduction 5

1 Building a half-car multibody model 7

1.1 Construction of a half-car model . . . . . . . . . . . . . . . . . . 81.2 Simulation performance . . . . . . . . . . . . . . . . . . . . . . . 14

2 Verification & error handling 16

2.1 Testcase 1: absent connection between joint and car-body . . . . 16

2.2 Testcase 2: mass not specified, equal to zero . . . . . . . . . . . . 18

3 Numerical accuracy 20

3.1 Analytical model . . . . . . . . . . . . . . . . . . . . . . . . . . . 20

3.2 Simulated model . . . . . . . . . . . . . . . . . . . . . . . . . . . 223.3 Comparison . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25

4 Visualisation of multibody models 27

5 Parametrisation of model variables 305.1 Specifying global parameters in Simulink/SimMechanics . . . . . 30

5.2 Specifying global parameters in MapleSim . . . . . . . . . . . . . 31

5.3 Specifying global parameters in Dymola . . . . . . . . . . . . . . 32

5.4 Dymola’s ’Experimentation Package’ . . . . . . . . . . . . . . . . 32

6 Exporting and interchangeability 35

6.1 MapleSim . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35

6.2 Dymola . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36

7 Closed-loop systems behaviour 38

2

Page 4: SimMechanics, MapleSim and Dymola: a first look on three

CONTENTS 3

8 Dymola Vehicle Dynamics Library 43

8.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 438.2 Adaptability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43

8.3 Visualization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 478.4 Performance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48

9 Conclusion 50

References 53

A SimMechanics windows 54

B MapleSim windows 56

C Dymola windows 59

D MapleSim C-code 65

Page 5: SimMechanics, MapleSim and Dymola: a first look on three

Abstract

In this report, an comparison between three multibody packages (Simulink/Sim-Mechanics, MapleSim and Dymola) is made in order to check whether or notMapleSim or Dymola would be an suitable alternative to the now used multi-body software SimMechanics. Some important aspects are investigated by us-ing some simple models. A half-car is constructed and analysed from which isconcluded that no big differences in simulation speed are present, but this ismainly due to the simplicity of the investigated models. Based on two testcases,an opinion regarding verification and error handling is given. By using a doublependulum system, a comparison is made based upon the accuracy of all threepackages. This is done by comparing the results that the software gives withthe results of an analytical derived equation of motion. Both MapleSim andDymola are offering build-in functionalities for parametrization of model vari-ables which are investigated in this report. It is concluded that most of thesefunctions could also be accomplished by making a few lines of code in MAT-LAB. The interchangeability functionalities are also investigated. In MapleSim,C-code can be exported use in for example MATLAB/Simulink. Dymola offersa functionality called the ’DymolaBlock’. This block can be used in a Simulinkenvironment to load a model made in Dymola directly into the Simulink model.Closed-loop behaviour is checked by means of deliberately miss-aligning twocomponent of a closed-loop system. It is checked how the software reacts to thisand if and how the error is reported. Finally, the ’Vehicle Dynamics Library’from Dymola is studied. An example model is investigated and a conclusionis made regarding adaptability of models. Also, visualization and performanceaspects are discussed.

4

Page 6: SimMechanics, MapleSim and Dymola: a first look on three

Introduction

Because of the continuous increase of computer power, the use of simulationtools is still growing. Multibody software for vehicle dynamics has been gainingpopularity thanks to advantages the use of this type of software brings. Nowa-days many companies produce multibody software tools and thanks to this, thesoftware is still getting better, faster and more reliable.

Until now, Eindhoven University of Technology (TU/e) has primarily beenusing the multibody software called ’SimMechanics’ which is part of MAT-LAB/Simulink. This product is very widely used and has a great number ofusers around the world. One drawback of SimMechanics is the limited process-ing speed which makes it nearly impossible to perform real-time simulations.Another drawback is the lack of modern and fast visualization possibilities. Anoverall view concerning SimMechanics is that it lacks development pace overthe past years.

TU/e is exploring alternatives concerning multibody packages that can performat least the same tasks as SimMechanics and should be faster regarding com-putation speeds and offers better possibilities to create code which is used forreal-time capable models. In order to find a possible substitute for SimMechan-ics, two new multibody packages have been examined.

The first package that is examined and compared to SimMechanics is called’MapleSim’ (version 1.0). This package is created by the company ’MapleSoft’and runs on the mathematical engine from Maple (version 12.02). The secondpackage is called ’Dymola’ (version 7.1) and is created by the company ’DynasimAB’.

In chapter 1, a simple half-car model is build in all three packages, so that userfriendliness of the software can be examined. Also, different aspects of buildingand analyzing a model are treated in this chapter. In chapter 2, the same half-car model is used to investigate how the packages deal with modelling errorsand how they do inform the user. After this, in chapter 3 a double pendulummodel is constructed. By means of this model, the numerical accuracy of allthree packages is studied. In chapter 4, the visualization possibilities of thethree multibody packages is explored. Chapter 5 deals with the parametrisationaspect of multibody models. By parametrize specific model variables, a modelcan be evaluated by varying some pre-defined model-properties. In chapter 6,interchangeability is discussed. By exporting models to C-code, this fast andefficient code can be used to perform for example ’Hardware In the Loop’ (HIL)simulations. Chapter 7 deals with a special but common kind of multibody

5

Page 7: SimMechanics, MapleSim and Dymola: a first look on three

CONTENTS 6

systems, so called ’closed-loop systems’. In this chapter we investigate how thepackages deal when components are not fully aligned to each other. Chapter 8of this report handles the Dymola Vehicle Dynamics Library. Different aspectsof this library are discussed and explained.

Acknowlegments

First of all, special thanks goes to my supervisor Igo Besselink for the help withthe project and creating the report. Furthermore, I want to thank Gosé Fis-cher of CANdiensten, for providing MapleSim and helping me with problems orquestions about MapleSim. Also I want to thank Mike Dempsey of Claytex Ser-vices Limited for providing Dymola and helping me with problems or questionsconcerning Dymola and the Vehicle Dynamics Library.

Disclaimer

This report is the work of a Bachelor student and does not necessarilyreflect the opinion of the Eindhoven University of Technology in gen-eral. The student has previous experience with MATLAB/Simulink,but no experience with SimMechanics, MapleSim or Dymola at thestart of the project. The student has spent about 15 weeks to studythe different packages and to do the analysis described in this report.

Page 8: SimMechanics, MapleSim and Dymola: a first look on three

Chapter 1

Building a half-car multibodymodel

In this chapter we will consider how models are constructed in both Simulink/Sim-Mechanics, MapleSim and Dymola. In the first section of this chapter, theModelica Language is discussed. This language is used to construct models inboth MapleSim and Dymola. In order to give an objective view of all threepackages, in the second section a relative simple half-car model is modeled. Dif-ferent aspect regarding usability of the software and construction of models arediscussed.

The Modelica Language

Both Dymola and MapleSim make use of the Modelica language. Modelica isa free object-oriented modeling language with a textual definition to describephysical systems in a convenient way by differential, algebraic and discrete equa-tions. An example such a textual representation of a model is showed in figure1.1.

The text in this figure represents a parallel spring-damper component. In thetop of the screen some parameters and input files are stated after which theactual equation of motion (f = c(s− s_unstretched) + ds) is introduced. Onecan easily identify s as being the prolongation of the spring and c and d as beingthe stiffness and damping-coefficient of respectively the spring and the damper.der(s) means the derivative of s, the elongation of the spring.

The Modelica language is suited for multi-domain modeling and involves forexample mechanical, electrical or hydraulic applications. In order to guaranteethe interoperability of the modeling language, a free ’Modelica Standard Library’is available. Furthermore, more both free and commercial Modelica libraries areavailable.

An elaborate description of the Modelica language and a user manual/handbookcan be found in [4].

7

Page 9: SimMechanics, MapleSim and Dymola: a first look on three

CHAPTER 1. BUILDING A HALF-CAR MULTIBODY MODEL 8

Figure 1.1: An textual representation of a parallel spring-damper component

1.1 Construction of a half-car model

In order to give an opinion about the user friendliness of all three packages, ahalf-car model (illustrated in figure 1.2) is constructed. The model consists of asprung car-body mass and two unsprung masses that represents the suspension-and wheel-masses. Two spring-damper components represents the suspensionof the half-car. Tyre-stiffness is introduced by means of a spring between theroad-profile and the unsprung masses.

Page 10: SimMechanics, MapleSim and Dymola: a first look on three

CHAPTER 1. BUILDING A HALF-CAR MULTIBODY MODEL 9

The numerical values of the model parameters are:

m_sprung = 700 [kg]

I_z = 1000 [kgm2]k_rear = 25000 [N/m]k_front = 18000 [N/m]d_rear = 1800 [Ns/m]d_front = 1500 [Ns/m]

m_unsprung_rear = 45 [kg]m_unsprung_front = 40 [kg]

k_tyre = 2e5 [N/m]

Because a variable road height profile is used as an input to simulate the re-sponse of the half-car, the vertical tyre force is dependent from both the verticalposition of the unsprung mass as from the height of the road-surface. Therefore,the vertical tyre force is calculated as the distance between the road and theunsprung mass multiplied with the vertical tyre stiffness. The resulting signalis applied to the unsprung mass as a force which is acting in vertical direction.

Sprung mass

Unsprung mass

Road profile

Spring/damper

Tyre spring k_tyrek_tyre

m_unsprung_frontm_unsprung_rear

k_reard_rear

k_frontd_front

m_sprungI_z

Figure 1.2: A graphical representation of a half-car model

SimMechanics

In SimMechanics, models are constructed by dragging components from the’Simulink Library Browser’ into the modeling window. The SimMechanicsmodel of a half-car is showed in figure 1.3. By clicking a specific component,parameters and settings can be changed (see figure A.1 in Appendix A for

Page 11: SimMechanics, MapleSim and Dymola: a first look on three

CHAPTER 1. BUILDING A HALF-CAR MULTIBODY MODEL 10

the car-mass block). In SimMechanics, coordinate frames are attached to thebody. Subsequently, joints are attached between these coordinate frames. A’planar’-joint is placed between the car-body and the ground-frame to enable a2D-motion of the model. The spring and damper are accounted for by attachinga so-called ’Joint Spring & Damper’ to a prismatic joint between the unsprungmass and the car-body. By attaching a ’Body-Sensor’ to a coordinate frame portof the unsprung mass body, the height of the body can be measured and again beused as a input signal. Since this component measures the position of the bodyin all three directions, the easiest way is to use a so called ’demux’-block. Usingthis block, we can specify which components of the signals to use. The numbernext to the line between the ’Body-Sensor’ and the ’demux’-block indicates thatwe are dealing with 3 signals. From the ’demux’-block it is unclear which signalswe selected, so this has to be determined by experimentation. The road-profileis introduced by specifying a road-height signal (as a function of the horizontalcoordinate) in a 1D look-up-table. Depending on the horizontal position of theunsprung mass, a road-height is calculated, which is subtracted from the verticalposition of the mass. By multiplying this signal with a constant (tyre-stiffness),a vertical spring-force is obtained. This force is applied to the unsprung massusing a ’Body-Actuator’ that is connected to the desired coordinate-system ofthe body.

Figure 1.3: The half-car model in SimMechanics

Page 12: SimMechanics, MapleSim and Dymola: a first look on three

CHAPTER 1. BUILDING A HALF-CAR MULTIBODY MODEL 11

Results can be loaded into the MATLABWorkspace by connecting a ’ToWorkspace’-block to a specific signal obtained from e.g. a ’Body-Sensor’. During simulation,signals can be graphically presented using a ’scope’ (see figure A.2 which repre-sents the vertical position of the unsprung mass). This ’scope’ can be attacheddirectly to a signal-line and is showed automatically when simulating the model.

When double-clicking a specific component, the parameters-window appearswhere also a brief description of the component is found. When right-clickinga model and choose ’Help’ a more elaborate description of the specific model isshowed in a separate screen.

MapleSim

Just like with SimMechanics, components are dragged from the ’Library Browser’into the modeling screen. As can be seen in figure 1.4 just like SimMechanics,the model consists of a sprung mass, two unsprung masses, a world frame andother components needed for simulating the tyre-force. The main difference withSimMechanics is the construction of coordinate frames. In contrary to SimMe-chanics where these frames were specified within the body block, in MapleSimextra frames are constructed by adding so-called ’Rigid Body Frames’. Theseblocks can be used to construct a fixed translation and rotation with respect toanother coordinate frame. Another difference with respect to SimMechanics ishow the spring-damper is constructed. Whereas SimMechanics requires the useof an extra ’Joint Spring & Damper’-block, MapleSim has an option to specifystiffness and damping directly within the ’Prismatic Joint’-block. Tire stiffnessis accounted for in basically the same way as was done in SimMechanics, againthe ’demux’-block does not specify which signal is extracted. By clicking a com-ponent, the ’Parameters’ window on the right of the screen displays the possibleparameters that are applicable for the concerning component. An example ofsuch a screen is given in figure B.1 for one of the unsprung masses. As canbe seen, for this component, mass-properties can be specified as well as someinitial position and orientation properties. A nice feature of MapleSim is the’Components’-window (see figure B.2). In this window, a hierarchic view of themodel is given. Using this window, all components that are present in the modelcan be seen at a glance. When selecting a component, the connection-ports ofthat specific part are displayed. After right-clicking a component and selectingthe ’Help on ...’ line, elaborate information about the specific component isshowed in a separate help-window.

As can be seen in figure 1.4, for some specific components MapleSim uses differ-ent colors for connection-lines and different connection-port-symbols. By doingthis, it’s easy to make a distinction between different sort of signals such asmultibody-signals, 1D-mechanical-signals or normal signal lines and betweeninputs or outputs. A elaborate explanation about all signals and symbols arefound in the MapleSim user-manual.

Results can be plotted by attaching probes to the connection lines of the model.In contrast to the probes in SimMechanics, MapleSim cannot ’live-visualize’ sig-nals. When attaching a probe, a screen appears in which the desired outputsignal(s) can be chosen (see figure B.3). After attaching probes and specify-

Page 13: SimMechanics, MapleSim and Dymola: a first look on three

CHAPTER 1. BUILDING A HALF-CAR MULTIBODY MODEL 12

Figure 1.4: The half-car model in MapleSim

ing signals, x- and y-axis variables have to be chosen (see figure B.4). Aftersimulating, a ’Plot Window’ appears (see figure B.5). In this window, line andaxis properties can be changed. Also, graph can be exported to various type ofimage-formats.

Dymola

In Dymola, the half-car model is constructed in basically the same way as wasdone in MapleSim (see figure 1.5). Again, components are dragged from the li-brary into the modeling-window. The car-body is modeled as a ’bodyShape’which can be interpreted as being a mass with two coordinate-frames, justlike what was done in MapleSim using a body block with two ’Rigid BodyFrames’. By using an ’Absolute Position’-block, we can extract the horizontaland vertical position signal of the body. Here, we don’t need an ’demux’-blockbecause Dymola directly asks which signal to use when dragging a line fromthe ’Absolute-Position’-block (see figure C.1). Parameters can be changed bydouble-clicking a component, an example of the ’parameter-window’ is showedin figure C.2 for the car-body. Other than MapleSim and SimMechanics, Dy-mola shows some parameters such as mass and stiffness/damping directly intothe top-view which is particularly handy when checking the model. By clicking

Page 14: SimMechanics, MapleSim and Dymola: a first look on three

CHAPTER 1. BUILDING A HALF-CAR MULTIBODY MODEL 13

’Info’ in the ’parameters’-window, an elaborate description of the selected com-ponent appears in a new help-window. Like MapleSim, Dymola uses differentcolors for connection lines specifying the signal-type.

Similar to MapleSim, Dymola also offers a ’Component-Browser’, showed infigure C.3. Like MapleSim, the browser represents a hierarchic view of thecomponents that are present in the model, as well as the connection-ports of aspecific component. By right-clicking a component in the browser and choosefor ’Info’, a similar information-window as discussed above will appear.

Figure 1.5: The half-car model in Dymola

An advantage of Dymola with respect to MapleSim and SimMechanics is thatall input and output signals can be plotted after the model has been simulated.Therefore, in Dymola no probes have to be attached to the model and no axis-properties have to be specified before simulating a model. If needed, adjustingthe plot characteristics can be done after simulating the model, using the ’plot-setup’-window (see figure C.4).

Page 15: SimMechanics, MapleSim and Dymola: a first look on three

CHAPTER 1. BUILDING A HALF-CAR MULTIBODY MODEL 14

1.2 Simulation performance

As will be discussed in more detail in section 3.3, when using default simulationsettings, big differences in accuracy can occur. Inevitable, this also influences theperformance and speed of a simulation. Therefore, the same simulation settingsas described in section 3.3 are used, because these settings give basically thesame results with respect to accuracy. By using these simulation settings, aglobal indication regarding simulation-speed can be given.

To check performance, the half-car-model is used again. The half-car model issimulated for 10 seconds. The numerical integrator settings (error tolerances andalgorithms) are adjusted so that they are identical (as far as possible) in all threepackages. The simulations are done with the same 1.86 GHz processor laptopthat is freshly started every simulation to guarantee identical circumstances.Nevertheless, no ’strict’ conclusions concerning simulation-speed can be madebecause of the relative simplicity of the half-car model and because of structuraldifference between the investigated multi-body packages. An example of this canbe given when we look at the way results are presented; in Dymola all signalscan be accessed after simulation, in SimMechanics and MapleSim distinctiveresult-signals have to be chosen prior to simulation.

In SimMechanics, the total simulating time for the half-car model is about 22seconds. No additional information regarding the time needed for compiling themodel equations and solving the equations is available.

Simulating the half-car model in MapleSim takes approximately 19 seconds intotal from which, according to the status-window, about 7 seconds in used forcompiling the model equations and about 12 seconds is needed for solving theequations and make data plots.

When we, under similar conditions, simulate the half-car model in Dymola,we can see that Dymola requires about 13 seconds simulation time. The timeneeded for translating the model is about 10 seconds, the residual 3 seconds areused to integrate the model-equations and process the data.

Another aspect of software-performance that has to be mentioned is startup-time. When we look at MapleSim, the software itself is ready-to-use in about 20seconds and the half-car model is loaded in about 2 seconds. Dymola requires10 seconds for initializing and a model is opened in approximately 5 seconds.Because the slow-loading MATLAB software is needed to use Simulink/SimMe-chanics, starting-up SimMechanics requires significant more loading-time com-pared to MapleSim and Dymola. SimMechics is ready-to-use after about 80seconds (which includes starting MATLAB and Simulink). Opening a modeltakes another 8 seconds.

From the preceding experience, we can conclude that Dymola is the fastestwith simulating the half-car model, but the differences with MapleSim and Sim-Mechanics are not significant. Nevertheless, the results give a first indicationregarding the simulation speeds. However, this simple half-car model does notrepresent the practical use of a multibody package where much more complicatedmodels will be created. When we really want to check if major differences insimulation time would occur, three extensive identical models should be build

Page 16: SimMechanics, MapleSim and Dymola: a first look on three

CHAPTER 1. BUILDING A HALF-CAR MULTIBODY MODEL 15

in all three packages. What we can conclude regarding start-up time is thatSimulink/SimMechanics needs significantly more time to start than MapleSimand Dymola. The start-up time differences between MapleSim and Dymola arein the order of seconds, in favour of Dymola.

Page 17: SimMechanics, MapleSim and Dymola: a first look on three

Chapter 2

Verification & error handling

When constructing complex models, it’s important that possible modelling er-rors can be traced efficiently. Therefore, error-messages given by the softwareshould be clarifying in order to localize the error.

In order to check error-messages and verification, two half-car model (see chapter1) test-cases are examined in which we deliberately cause an error. In the firstcase, we ’forget’ to attach one of the prismatic joints to the car-body. In thesecond case, we don’t specify a mass-value to the car body. In both cases weinvestigate how the three packages react and how they report the error. Thequestion ’can we efficiently trace the fault by looking to the error-message?’ isanswered after that.

2.1 Testcase 1: absent connection between jointand car-body

SimMechanics

When performing testcase 1 to the SimMechanics model, an error-message asshowed in figure 2.1 appears. The message is not directly indicating where thefault occurs in the model, but from the fact that there is, however, a ’Ground-block’ present in the model we can conclude that somewhere, the rest of themodel is not connected to it.

MapleSim

If we look at the error-message which is produced in MapleSim (see figure 2.2) wesee a error-message which is explained by means of an error in the mathematiccalculation. From this message we haven’t got a clue where to find the fault andwhat causes it. Because of these ’cryptic’ error messages, in practice it’s veryhard to construct a model for the first time because no clear information about

16

Page 18: SimMechanics, MapleSim and Dymola: a first look on three

CHAPTER 2. VERIFICATION & ERROR HANDLING 17

Figure 2.1: SimMechanics error message belonging to testcase 1

the location and characteristic of the fault is given when the model contains anerror.

Figure 2.2: MapleSim error message belonging to testcase 1

Dymola

When performing the same testcase in Dymola, an error-message like figure2.3 appears. From the sentences "Connector frame-b of joint object is not con-nected" and "Connector frame-b of line force object is not connected" it becomesvery clear what was done wrong and where the fault is located in the model.

Page 19: SimMechanics, MapleSim and Dymola: a first look on three

CHAPTER 2. VERIFICATION & ERROR HANDLING 18

Figure 2.3: Dymola error message belonging to testcase 1

2.2 Testcase 2: mass not specified, equal to zero

SimMechanics

When looking at the error-message produced by SimMechanics (see figure 2.4),from just reading the message that the mass of the car body is not specified.

Figure 2.4: SymMechanics error message belonging to testcase 2

MapleSim

In MapleSim, a value which is obliged (such as the mass of a body) cannot bedeleted. When trying to escape the default value, it is changed into a value of1 [kg].

Dymola

When in Dymola deliberately a mass-value is not specified, the program doesnot produces an error-message. Apparently, a default value is chosen if novalue is specified. When we look at the plots to check this, we indeed can seethat Dymola uses a default value of 1 [kg] for the mass of the car-body, withoutinforming the user. This can be a bit tricky, because the behavior of the half-car

Page 20: SimMechanics, MapleSim and Dymola: a first look on three

CHAPTER 2. VERIFICATION & ERROR HANDLING 19

becomes completely different. What we do see is that the mass-value indicatedin the top-screen of the model is changed into m which indicates that no numericvalue for the mass of the car-body has been chosen.

Page 21: SimMechanics, MapleSim and Dymola: a first look on three

Chapter 3

Numerical accuracy

In order to check the numerical accuracy of all three packages a relative simple2D double pendulum model is modeled. By comparing the resulting motioninduced by two initial conditions (for both θ1 and θ2) with an analytical derivedequation, the software accuracy can be checked. A schematic drawing of theanalysed double pendulum is showed in figure 3.1. The masses m1, m2 and alsothe length l1 and l2 of the pendulum are kept constant in all simulations. Theinitial condition are also kept constant and will be θ1 = pi

4 and θ2 = 0.

m_1

m_2

l_1

l_2

θ1

θ2

Figure 3.1: The double pendulum reference model

3.1 Analytical model

The double pendulum system will be analysed by hand using the Langrangianmethod (3.1).

20

Page 22: SimMechanics, MapleSim and Dymola: a first look on three

CHAPTER 3. NUMERICAL ACCURACY 21

d

dt

(T,q)− T,q + V,q = (Qnc)T (3.1)

Where the generalized coordinates are chosen to be:

q =[q1q2

]=[θ1θ2

](3.2)

and the kinetic energy:

T =12qT Mq (3.3)

with M the mass-matrix of the system:

M =n∑

i=1

mi(ri,q)T ri,q (3.4)

where ri,q represents the derivative of the position vector of mass mi withrespect to the generalized coordinates (3.2).

The mass-matrix becomes:

M =[

(m1 +m2)l21 m2l1l2(cosθ1cosθ2 + sinθ1sinθ2)m2l1l2(cosθ1cosθ2 + sinθ1sinθ2) m2l

22

](3.5)

and using this result the kinetic energy T becomes:

T =12m1l1θ1

2+

12m2(l21θ1

2+ l22θ2 + 2l1l2θ1θ2cos(θ1 − θ2)) (3.6)

Because no springs are involved in the system the potential energy becomes:

V = U in(q) + V ex(q) = V ex(q) (3.7)

and thus becomes:

V = −m1gl1cosθ1 −m2g(l1cosθ1 + l2cosθ2) (3.8)

And because no non-conservative forces are involved:

Qnc = 0 (3.9)

When vector equation (3.1) is evaluated and then rewritten to θ1 and θ2 as afunction of θ1, θ2, θ1 and θ2 (angles and angular-velocity of both generalizedcoördinates), two second order differential equations of motion are obtained:

Page 23: SimMechanics, MapleSim and Dymola: a first look on three

CHAPTER 3. NUMERICAL ACCURACY 22

θ1 =(m2gsinθ2B −m2l2θ2

2A− Cgsinθ1−

m2l1θ12AB)/(Cl1 −m2l1A

2) (3.10)

θ2 =(m2l2θ2

2AB + Cgsinθ1cos(θ1 + θ2)+

Cl1θ12A+ Cgsinθ2

)/(Cl2 −m2l2B

2) (3.11)

With:

A = sin(θ1 − θ2)B = cos(θ1 − θ2)C = (m1 +m2)

Using Matlab’s ODE45 integration method, differential equations (3.10) and(3.11) are solved numerically. The results are plotted as θ1 against θ2 in figure3.2 for 0 ≤ t ≤ 5s.

Figure 3.2: Plot of the double pendulum motion

3.2 Simulated model

The double pendulum system is modeled in all three multibody packages. Byusing the same parameters and initial conditions as in the analytical model, anindication regarding the accuracy of all three programs can be made.

Page 24: SimMechanics, MapleSim and Dymola: a first look on three

CHAPTER 3. NUMERICAL ACCURACY 23

SimMechanics

First off all, the double pendulum is modeled in SimMechanics. The modelconsists of a world reference, two point masses and two revolute joints. Twoinitial conditions are given via the ’Joint Initial Condition’ component in whichthe intitial angles θ1 and θ2 are specified.

Figure 3.3: Visualisation of double pen-dulum in SimMechanics

Figure 3.4: Model of double pendulumin SimMechanics

MapleSim

The double pendulum is also modeled in MapleSim. Again, the model consists ofa world reference, two body’s with zero inertia (point masses) and two revolutejoins. The initial conditions are given within the joint-block in contrary toSimMechanics which uses an extra ’Initial Condition’ attached to the joint.

Dymola

Finally, the double pendulum is modeled in Dymola. As in SimMechanics andMapleSim, the model again consists of a world reference, two body’s and tworevolute joints. The initial conditions are (as in MapleSim) specified within thejoints.

Page 25: SimMechanics, MapleSim and Dymola: a first look on three

CHAPTER 3. NUMERICAL ACCURACY 24

Figure 3.5: Model of double pendulum in MapleSim

Figure 3.6: Visualisation of double pen-dulum in Dymola

Figure 3.7: Model of double pendulumin Dymola

Page 26: SimMechanics, MapleSim and Dymola: a first look on three

CHAPTER 3. NUMERICAL ACCURACY 25

3.3 Comparison

In this section the absolute errors of the different packages with respect to the an-alytical model are examined. By choosing very small absolute and relative errortolerances (1e-9) for solving the stated ODE’s (3.10) and (3.11), this numericalsolution can be interpreted as the ’exact’ solution of the double-pendulum prob-lem and therefore differences with respect to the ’exact’ solution can be fullyattributed to errors made by the multibody package.

Default integrator settings

First, a comparison is made based on the default settings of the three multibodypackages. Only the simulation time and the number of time-steps is adjusted(in order to compare the results).

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5−1.5

−1

−0.5

0

0.5

1

1.5

2

2.5x 10

−3

time [s]

erro

r[rad

]

Absolute error in θ1

SimMechanicsMapleSimDymola

Figure 3.8: Absolute error on θ1

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5−3

−2

−1

0

1

2

3x 10

−3

time [s]

erro

r[rad

]Absolute error in θ2

SimMechanicsMapleSimDymola

Figure 3.9: Absolute error on θ2

As can be seen in the preceding plots, the absolute error of Dymola is muchgreater than that of Simulink and MapleSim. This can be explained if we look atthe simulation settings. Where Simulink and MapleSim both are using a defaulterror tolerance (for both absolute and relative error) of 1e-7, Dymola uses anerror tolerance of 1e-4. As well, by default Dymola uses a different numericalmethod for solving ODE’s, namely the ’Dassl’-algorithm, where Simulink andMapleSim both use an algorithm based on the ’Runga-Kutta’-method (for non-stiff systems). As can be seen, the absolute error for all three packages does notexceed 3 · 10−3 [rad].

Page 27: SimMechanics, MapleSim and Dymola: a first look on three

CHAPTER 3. NUMERICAL ACCURACY 26

Manual setup

In this section similar settings as those of SimMechanics and MapleSim arechoosen. The same error tolerance (1e-7) is chosen as well as a solver based onthe Runga-Kutta method is used in all three packages. When choosing similarsettings, we can check if the absolute errors stay small and see if the errors ofall three packages are in the same order of magnitude.

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5−3

−2

−1

0

1

2

3

4

5x 10

−7

time [s]

erro

r[rad

]

Absolute error in θ1

SimMechanicsMapleSimDymola

Figure 3.10: Absolute error on θ1

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5−4

−3

−2

−1

0

1

2

3x 10

−7

time [s]

erro

r[rad

]

Absolute error in θ2

SimMechanicsMapleSimDymola

Figure 3.11: Absolute error on θ2

According to figure 3.10 and 3.11 the absolute error of Dymola is lowered witha factor 1e4. This was expected from the fact that the error tolerance in Dy-mola was lowered to 1e-7 (in consensus with tolerances used in MapleSim andSimulink). Also, a ’Dormand-Prince’ method (member of the Runga-Kuttasolver) was now used for solving the ODE’s. The absolute error for both θ1 andθ2 now stays within 3 · 10−7 [rad] for all three packages. What is notable is thatthe Dymola result is more noisy compared to the other packages and SimMe-chanics still has the smallest error, but is difficult to make a conclusion fromthis: although the three packages use a member of the Runga-Kutta methodfor solving the differential equations, the solvers still are not 100% comparable.

Page 28: SimMechanics, MapleSim and Dymola: a first look on three

Chapter 4

Visualisation of multibodymodels

An important aspect of multibody-software is visualization. With the help ofa visualization screen, the assembly of a constructed model can be checked aswell as the motion of the model that is being simulated. Possible errors thatwere made constructing the model (especially when it comes to composition ofbodies) are noticed at a glance. Especially when first using multibody-software,such composition-errors are easily made and very hard to find if only plotteddata is produced. The same half-car-model used in chapter 1 is used here toexamine the visualization-aspect.

SimMechanics

SimMechanics offers different ways of visualizing models. First of all, a defaultview can be used in which only ’centers-of-gravity’, ’coordinate-frames’ and’body-geometries’ (geometries according to specified coordinate-frames) (see fig-ure 4.1). Since the R2008b-release of Matlab, SimMechanics offers an optionto attach user-made .stl-graphics to bodies. In figure 4.2 this was done forthe half-car-model by attaching simple rectangles to the sprung mass and thetwo unsprung masses. Graphics cannot be attached to joints or spring-dampercomponents.

During a simulation, the model can be turned, panned and zoomed to investigatea particular component. The animation can be stored into a .avi-file.

MapleSim

A big drawback of the current MapleSim release is that it does not include anyvisualization functionality. Therefore verification of a constructed model canonly be done by checking plots, no visual inspection of the modelled system ispossible.

27

Page 29: SimMechanics, MapleSim and Dymola: a first look on three

CHAPTER 4. VISUALISATION OF MULTIBODY MODELS 28

Figure 4.1: Visualization of the half-carmodel in SimMechanics

Figure 4.2: Visualization of the half-carmodel using user-defined .stl-graphics

It has to be mentioned that as of may 2009, a new MapleSim version is released(MapleSim 2.0). In this version, a powerful new visualization functionality isintroduced. Because of the time-limitation to which this analysis is bound,this new functionality will not be covered here. However, the new MapleSim2.0 visualization environment was tested briefly and from the first sight, thevisualization functionality is working very smooth and responsive.

Dymola

Dymola also offers a visualization functionality, see figure 4.3 for the half-car-model. Nevertheless, it’s far more elaborate than that of SimMechanics. Wherein SimMechanics no visualizations can be attached to components other thanbodies, Dymola has a build-in visualisation for springs, dampers and joints, andby changing animation-parameters, the way components are displayed in thevisualization can be changed. An example is given in figure C.5 where settingscan be made for the spring-damper component. Again, the model can be turned,panned and zoomed similar to SimMechanics. One thing that is notable whenusing the Dymola visualization mode, is that it is working much ’smoother’ thanthat of SimMechanics. Especially when moving and zooming a model during asimulation, it is much more responsive and graphics are of much higher qualityin comparison with SimMechanics’ visualization-mode.

Page 30: SimMechanics, MapleSim and Dymola: a first look on three

CHAPTER 4. VISUALISATION OF MULTIBODY MODELS 29

Figure 4.3: Visualization of the half-car model in Dymola

Page 31: SimMechanics, MapleSim and Dymola: a first look on three

Chapter 5

Parametrisation of modelvariables

An important aspect of multibody software is parametrisation of the model.By assigning global parameters to a model, multiple individual componentscan inherit the specified value of this parameter. Therefore, multiple model-parameters can be adjusted by just altering one global-parameter.

Another important application of parametrisation is ’model-optimization’. Byvaring pre-defined parameters, physical models can be simulated for various con-figuration and by analysing the result an optimal value for a certain parametercan be chosen.

5.1 Specifying global parameters in Simulink/Sim-Mechanics

In SimMechanics, global parameters values are specified in the MATLAB workspaceand called from the model block-parameters. By constructing a m-file with allparameter-values and calling the SimMechanics model directly from this m-file,parameter values can be set and modified (see figure 5.1).

Figure 5.1: An m-file which runs the model with predefined global parameters

30

Page 32: SimMechanics, MapleSim and Dymola: a first look on three

CHAPTER 5. PARAMETRISATION OF MODEL VARIABLES 31

5.2 Specifying global parameters in MapleSim

In MapleSim, global parameters are assigned by clicking the ’parameters’ buttonwhich displays the ’Global Parameters’ view (see figure 5.2). After assigningsome global parameters, the parameter name and default value are displayed inthe parameters pane.

Figure 5.2: The ’Global Parameters’ view

Now, for example a global parameter called ’M’ can be assigned as a variable toa individual component and therefore inherit the value of the global parameter’M’. Not only single global parameters can be assigned to model variables, butalso functions of global parameters can be assigned to model parameters.

MapleSim offers an application called the ’Parameter Optimization Template’.This template (which opens in MapleSim’s mathematical engine Maple) canbe used to test different settings of the model by varying specified global pa-rameters. For each global parameter, a range of values can be specified (seefigure 5.3) for which the model is simulated after which the simulation result isvisualised in a plot automatically. The defined global parameters can also beassigned to a Maple procedure to perform further analysis tasks.

Figure 5.3: A part of the ’Parameter Optimization Template’

Page 33: SimMechanics, MapleSim and Dymola: a first look on three

CHAPTER 5. PARAMETRISATION OF MODEL VARIABLES 32

5.3 Specifying global parameters in Dymola

Just like MapleSim, Dymola also offers a possibility to specify globalparameteters and assign values to them. In Dymola however, parameters can beassigned as being real physical quantities such as length, time, volume, etc. Bydragging a physical variable into the Modelica Text Representation, a windowappears in which a discription, name and value can be assigned to a parameter(see figure 5.4) as well as some other parameter settings which is basically thesame as was done in MapleSim.

Figure 5.4: The physical parameter declaration window

After specifing some global parameters and assigning values to the parameters,similar to MapleSim global parameters can be assigned to components parame-ters that inherits the numeric value of the global parameter. Dymola also offersthe possibility to assign the parameter from a drop-down menu which is handywhen many parameters are specified or when the exact name of the parameteris not known. After entering the Dymola Simulation screen, global parametervalues can be varied between simulations.

5.4 Dymola’s ’Experimentation Package’

Similar to MapleSim’s ’Parameter Optimization Template’, Dymola offers alibrary called the ’Experimentation Package’ (see figure 5.5). The Experimen-tation Package provides several ways of analyzing the behavior of a model. Themain functions are perturbParameters, sweepParameter, sweepOneParameter,sweepTwoParameters and MonteCarloAnalysis.

By choosing the ’perturbParameters’-function, we can check the behavior of amodel by pertubating from a nominal value of a parameter. After choosing theparameters to perturb and the percent change of pertubation from the nominalvalue, a plot can be created which (after selecting the variable to plot) displaysthe response of the selected variable when varying a parameter. The verticaldisplacement response of a mass-spring system is plotted in figure 5.6 whereboth stiffness of the spring and the mass were pertubated 20% from the nominalvalue.

Another way of varying one parameter and check the resulting behavior of themodel is done by choosing the ’sweepParameter’-function. With this function,

Page 34: SimMechanics, MapleSim and Dymola: a first look on three

CHAPTER 5. PARAMETRISATION OF MODEL VARIABLES 33

Figure 5.5: The ’Experimentation Package’ library

one parameter can be varied over a specified interval by selecting the numberof (equidistant) values between this interval. The resulting output variable canagain be plotted in a specified time interval, for every parameter value specified.Some other methods for analysing a response are available, explanation andfunctionality of these methods can be found in the Dymola user manual.

To study the dependence of one response with respect to two parameters at theend of the integration interval, the function ’sweepTwoParameters’ is to be used.The setup is almost identical to ’sweepParameter’ and ’sweepOneParameter’.The only difference is that two dependency variables are to be selected instead.Consequently, a 3D-plot is generated for each output-variable.

Last but not least, a ’Monte Carlo Analysis’ can be used to analyse parameterbehaviour. The ’Monte Carlo Analysis’ is widely used to explore the behavior ofa model when the input parameters are multidimensional. For the exact usageand application of this function, the reader is referred to the Dymola manual.

Off course, the functionalities regarding parameter-variation offered by MapleSimand Dymola, as discussed in this chapter are effective when it is necessary to varyparameters and investigate behaviour. Nevertheless, in MATLAB/Simulinkmost of the results acquired by these functionalities can also be accomplishedby just making some loops in an MATLAB m-file, in which the model is called(see figure 5.1) and where also a range of values for specified parameters can beused.

Page 35: SimMechanics, MapleSim and Dymola: a first look on three

CHAPTER 5. PARAMETRISATION OF MODEL VARIABLES 34

Figure 5.6: Vertical displacement of the point-mass

Page 36: SimMechanics, MapleSim and Dymola: a first look on three

Chapter 6

Exporting andinterchangeability

MATLAB/Simulink is used in all sorts off disciplines. In practice, multibodydynamics often have to cooperate with other engineering disciplines (like elec-trical engineering, systems engineering, control, etc.). Besides, the fact thatMATLAB/Simulink is known by much TU/e students, the possibility to exportthe multibody model to MATLAB/Simulink is highly appreciable and of greatinterest.

In both MapleSim and Dymola, the model is exported to C-code. Thanks tothe compactness of this code and because it’s numerically very efficient due tosymbolic preprocessing, the code can be used to do real-time simulations or useit in HIL (Hardware In the Loop) applications.

6.1 MapleSim

In MapleSim, C-code is generated directly from the model equations by usingMapleSim’s mathematical engine, Maple 12. In this ’Code Generation Template’variables can be assigned, inputs and output can be specified and parameter val-ues can be changed. In the ’Model Equations’ window (see figure 6.1) the modelequations can be explored as well as the model’s parameters, initial conditions,probes and other information.

In order to investigate the generated C-code and check if it is understandableeven without knowledge of the model from which it arise from, an very simple(point)mass-spring system is modeled. By using distinct values for the mass(1.000123 [kg]), stiffness off the spring (1.23456789 [N/m])and the initial positionoff the mass (3.33445 [m] in vertical direction), we can easily identify them inthe C-code which is found in appendix A.

Firstly, some output and state variables are specified. We notice from the com-ment on line 17-31 that Probe1 is specified as an output variable. Some othervariables from the model are specified as state variables. On line 146 we can

35

Page 37: SimMechanics, MapleSim and Dymola: a first look on three

CHAPTER 6. EXPORTING AND INTERCHANGEABILITY 36

Figure 6.1: The ’Model Equations’ window

identify our mass and stiffness (both are multiplied by 108. As can bee seenfrom the code, even for simple code as this it’s hard to identify parameters ifthe exact value of these parameters is not known. For this part of the code, itwould be very handy if it had some more elaborate comment specifying whichparameters are being used an what expressions are being solved (expressed sym-bolical). In the lower part of the code initial conditions are specified in whichthe initial position of the mass is found.

Alternatively, MapleSim also offers a so called ’Connectivity Toolbox’. Thistoolbox enables users to export MapleSim models directly to Simulink. Modelsare automatically converted to S-function blocks which are directly usable inSimulink. Because this functionality is not a build-in feature of MapleSim andrequires the installation of extra software, it has not been examined in thisreport.

6.2 Dymola

Similar to MapleSim’s ’Connective Toolbox’, Dymola offers a functionality tocommunicate with MATLAB/Simulink called the ’Dymola-Simulink interface’.Unlike the ’Connective Toolbox’ from MapleSim, this is a build-in feature ofDymola. To use this function, the user should include a Dymola-folder in theMATLAB search path that contains some m-files. After this folder is included, a’Dymola-Simulink interface’ block called ’DymolaBlock’ appears in the SimulinkLibrary browser (see figure 6.2). This block with the Dymola logo representsthe model that is made using Dymola. The DymolaBlock is a shield aroundan S-function MEX block, i.e., the interface to C-code generated by Dymolafor the Modelica model. After compiling the model, the lines left and right ofthe DymolaBlock are replaced by ports that can be connected to all sorts off

Page 38: SimMechanics, MapleSim and Dymola: a first look on three

CHAPTER 6. EXPORTING AND INTERCHANGEABILITY 37

Simulink-components.

Figure 6.2: Simulink Library containing the ’DymolaBlock’

By double-clicking the DymolaBlock, a Graphical User Interface (GUI) is dis-played (see figure C.6). Using this GUI the DymolaBlock can be configuredwhich involves specifing the Modelica model, compiling the model into a SimulinkMEX file, selecting compiler options, setting and resetting parameters and startvalues, etc.

Dymola also offers some M-files that can be used to analyse and run modelsconstructed with Dymola using MATLAB. These M-files run a program called’Dymosim’. Dymosim essentially is a stand-alone program without any graph-ical user interface which reads the experiment description from an input file,performs one simulation run, stores the result in an output file and terminates.By using some pre-defined functions found in the M-files bundled with Dymola,output can be imported into MATLAB as plots, and signals can be extractedfrom files made by Dymosim. Also by specifying an input function, parameterscan varied.

Page 39: SimMechanics, MapleSim and Dymola: a first look on three

Chapter 7

Closed-loop systemsbehaviour

Closed-loop (or closed-chain) systems are a special, but common kind of multi-body systems. These type of systems require so called ’cut-joints’ to take care ofthe closed loop. An extra step has to be taken when the equations of motion arecompiled. The problem with modeling closed loop systems lies in the fact thatthe model can exhibit configuration singularities. Consequently, the solution ofthe kinematic analysis of such a system may, at a certain configuration, eithernot exists or not be unique. When modeling complex systems it is not alwaysclear to see where and when these singularities occur. Therefore, in this chaptera simple 2D 3-link closed loop mechanism is introduced (see figure 7.1) in whichthe right ground-frame deliberately placed 0.0001 meter sideways with respectto the lower-end of the right link. This issue occurs in lots of multibody systemsthat contain a closed-loop, where two specific bodies are attached together (orto the ground-frame) and do not exactly align with each other.

Lateral position error of 0.0001 m.

Figure 7.1: A 2D 3-link closed loop mechanism

38

Page 40: SimMechanics, MapleSim and Dymola: a first look on three

CHAPTER 7. CLOSED-LOOP SYSTEMS BEHAVIOUR 39

SimMechanics

As can be seen in figure 7.2, the closed-loop system as discussed above is modeledin SimMechanics. In this figure, we can see that a little red cross appears in oneof the joints which means that this joint is used as a ’cut-joint’. By assigning a’cut-joint’ in every independent closed-loop, the problem is solved in a standardway, taking into account that a closed loop is present in the system. A cut-jointis chosen automatically by SimMechanics but other joints can be specified asbeing the preferred cut-joint. After placing the right ground-block 0.0001 metersto the side (with respect to the lower coordinate frame of the vertical bar andsimulating the model, we observe that no error-messages appears. Only afterpositioning the ground-block as much as 0.1 meter to the side, an error messageas seen in figure 7.3 appears. From this we can conclude that SimMechanicsis using a tolerance when working with closed-loop systems. This means thatthe problem found in closed-loop modeling as stated in the introduction above,only occurs when bodies are seriously miss-aligned.

Figure 7.2: The closed-loop mechanism modeled in SimMechanics

MapleSim

When simulating the modeled closed-loop system in MapleSim (see figure 7.4)and constructing the ground-frame 0.0001 meters sideways (as explained in theintroduction above) a error-message appears. The error-message is viewed infigure 7.5. The same conclusions can be made as discussed in section 2.1: fromthis message we cannot identify the problem. According to the description inthe error-message we can only conclude that the problem is acting in ’R4’ whichis identified as the revolute-joint on the lower-right of the model, but nothing ismentioned about composition faults or a possible closed-loop error.

Page 41: SimMechanics, MapleSim and Dymola: a first look on three

CHAPTER 7. CLOSED-LOOP SYSTEMS BEHAVIOUR 40

Figure 7.3: SimMechanics closed loop error message

Dymola

First of all, when modeling a closed-loop mechanism in Dymola (see figure 7.6),the program advises you to use a so-called ’RevolutePlanarLoopConstraint’-joint in stead of the normal ’Revolute’-joint. This joint allows you to modelclosed-loop systems without having problems that are caused by singularitiesin the mathematical description of the model. How this is done exactly in Dy-mola, can be found in the user-manual. This feature can be compared withthe SimMechanics environment where (for closed-loop systems) a cut-joint isautomatically introduced. When simulating the stated model (with the rightground-frame positioned miss-aligned) Dymola behaves differently in compar-ison with SimMechanics: the placement of the right mass lower coordinate ischanged so that it meets the stated positioning of the right ground-frame. Byapplying initial conditions to the revolute-joints, this ’problem’ can be tackled.After applying these initial conditions and placing the ground frame 0.0001 me-ters sideways, an error message as can be seen in figure 7.7 appears. In thismessage screen, the reason that causes the error is shown as well as possiblesolutions (removing one of the initial conditions from the revolute joints). Itis not explicitely perceived that we are dealing with a closed-loop system, butfrom the hints stated in the error-message, we can conclude that the fault hasto be found in the initial composition of the model.

Page 42: SimMechanics, MapleSim and Dymola: a first look on three

CHAPTER 7. CLOSED-LOOP SYSTEMS BEHAVIOUR 41

Figure 7.4: The closed-loop mechanism modeled in MapleSim

Figure 7.5: MapleSim closed loop error message

Page 43: SimMechanics, MapleSim and Dymola: a first look on three

CHAPTER 7. CLOSED-LOOP SYSTEMS BEHAVIOUR 42

Figure 7.6: The closed-loop mechanism modeled in Dymola

Figure 7.7: Dymola closed loop error message

Page 44: SimMechanics, MapleSim and Dymola: a first look on three

Chapter 8

Dymola Vehicle DynamicsLibrary

At the Eindhoven University of Technology, an important application of themultibody package is vehicle dynamics. Because of the drawbacks consideringvisualisation and speed of MATLAB/Simulink a fast vehicle dynamics package ishighly appreciated. A free Modelica-based vehicle dynamics library is available,but this library is very limited and no further development on this library isdone. A more extensive commercial vehicle dynamics library is available andis designed and maintained by Modelon AB, the same company that producesDymola. Here, version 1.3 of the ’Vehicle Dynamics Library’ is used.

8.1 Introduction

The Dymola Vehicle Dynamics Library offers is, as with all Dymola libraries,based on the Modelica language which means that the details of the separatevehicle components are fully open to the user and gives more experienced userspossibilities to adapt or design their own components. As was also mentioned inchapter 1, additional Modelica libraries can be be used so that multiple engineer-ing domains such as control, hydraulics, powertrains and electrical system canbe covered. Besides some ready-made components like suspensions, brakes andpowertrain components, the Vehicle Dynamics Library also includes a 3D roadbuilder, a number of open- and closed-loop driver models, athmosphere-blocksand some state-of-the-art tyre models such as Rill and Pacejka.

8.2 Adaptability

In nearly all cases, academic usage of multibody packages and in particular avehicle dynamics library requires modeling custom (suspension-) components orediting existing components. Consequently, a component should be intuitivelyand clear. To check this, a ready-made ’Trailing Arm’ suspension is firstly

43

Page 45: SimMechanics, MapleSim and Dymola: a first look on three

CHAPTER 8. DYMOLA VEHICLE DYNAMICS LIBRARY 44

looked as a component itself. Adjustable settings and parameters are discussedafter which the underlying methodology is checked.

Figure 8.1: The ’Trailing Arm’ blockFigure 8.2: Expanded view of the ’Trail-ing Arm’ suspension

As can be seen in figure 8.1, the ’Trailing Arm’ block has got four frame connec-tions (rectangular ports), four spring-damper connections (square ports) thatcan be used to specify the position of both damper and spring mounts in theupright, see also figure 8.3, and one hub-flange (the rectangle with an circleinside) for attaching the wheel. By using the dotted lines in figure 8.1 and fromthe discription found when hovering over the ports, it is obvious how to attachthe suspension to the chassis and connecting the wheels to the suspension.

By clicking the ’Trailing Arm’ block, various parameters and settings consideringthe geometry of the suspension can be modified. As can be seen in figure 8.3, themeaning of specific parameters is very clear thanks to the elaborate discriptionand the drawing on the right.

When we look to the underlying components of the ’Trailing Arm’-block infigure 8.3, we can firstly identify all of the nine ports discussed above. Secondly,two suspension links can be seen as well as a joint connected to one of the links.Thirtly, we see a spring and damper which are attached to the other suspensionlink. By clicking a component, again different parameters such as mass andinertia for the link and stiffness and damping coefficients for the spring anddamper can be adjusted.

When going deeper into the ’LowerArm’-link, we can see a number of parts, ascan be seen in figure 8.4. We can see two ’FixedTranslations’ and three ’Rods’.The three ’Rods’-components are identified as being the three links of whichthe ’Lowerarm’ consists of. Again, different characteristics of the ’Rods’ can beadapted such as mass, inertia and geometry properties. In this case, geometryproperties are constructed by declaring a function of some global parametersspecified in second-level ’LowerArm’-block (which again are functions of param-eters specified in the top-level ’Trailing Arm’-block). An examle of this can be

Page 46: SimMechanics, MapleSim and Dymola: a first look on three

CHAPTER 8. DYMOLA VEHICLE DYNAMICS LIBRARY 45

Figure 8.3: The ’Trailing Arm’ parameters window

found in figure 8.4 where we can see that the position vector of ’link1’ is speci-fied as r = r0J1− r0B (see the top of the figure) where both r0J1 and r0B arespecified in the one level higher ’LowerArm’ block (not visualized here). Both’FixedTranslations’ are needed to specify the position of the two ’Rods’ relativeto both mounting-frames.

Finally, when looking into the lowest-level ’link1’-block (see figure 8.5), wefind two elementary Modelica-blocks, namely a ’body’-block which specifies themass- and interia-properties whereas the ’frameTranslation’-block represents theposition-vector of the rod. Parameters from both blocks are inherited fromhigher-level components.

Page 47: SimMechanics, MapleSim and Dymola: a first look on three

CHAPTER 8. DYMOLA VEHICLE DYNAMICS LIBRARY 46

Figure 8.4: The ’LowerArm’-block

Figure 8.5: The ’link1’-block

Page 48: SimMechanics, MapleSim and Dymola: a first look on three

CHAPTER 8. DYMOLA VEHICLE DYNAMICS LIBRARY 47

The hierarchic structure discussed above is (in a clarifying way) showed in the’Component Browser’ (see figure 8.6). In this browser, all the different compo-nents with their specific ports can be found. By clicking on it, the componentopens in the modeling-window. By right-clicking a component, parameters canbe changed without opening the specific component. From the preceding textit can be concluded that the vehicle component that was looked at (the Trail-ing Arm suspension) is fairly understandable when going deeper into the model.Parameters and settings can be adapted easily. Also, it can be seen that the dif-ferent rods and links are easily identified and therefore their composition couldbe changed easily. The lowest level components are simple standard Modelicacomponents which would make it possible to construct a suspension-part fromscratch.

Figure 8.6: The Dymola ’Component Browser’

8.3 Visualization

A powerful aspect of Dymola’s ’Vehicle Dynamics Library’ is the visualiza-tion of models. Many basic ready-made components found in the library offerthe possibility to be visualized while running the simulation. Some of the 3-dimensional illustrations used to visualize the components are deformable andmovable. Thanks to this, springs for example can be visualized realistically. Anumber of properties of the 3D visualization such as color (material finish) anddimensions can also be changed (see figure C.7 for a spring-damper-component).

Page 49: SimMechanics, MapleSim and Dymola: a first look on three

CHAPTER 8. DYMOLA VEHICLE DYNAMICS LIBRARY 48

Also road-surfaces can be visualized. During a simulation, models can be turnedand scaled.

In figure 8.7 a visualization of a 3D-car model is shown. Figure 8.8 shows adetailed view of the suspension.

Figure 8.7: Visualization of a car

Figure 8.8: Detailed view of the suspension with spring-damper, wheel andbrake

8.4 Performance

Due to the fact no other similar vehicle-models are available in the other pack-ages, it’s hard to make conclusions considering simulation-performance. Otherthan that, comparable settings regarding the used algorithm and error-toleranceshave to be chosen to give an objective view on the performance aspect.

To check performance, let’s take the ’VehicleDynamics.Examples.GettingStarted.GettingStarted’-example model of a typical mid-size car provided standard in the library which

Page 50: SimMechanics, MapleSim and Dymola: a first look on three

CHAPTER 8. DYMOLA VEHICLE DYNAMICS LIBRARY 49

performs a pre-defined steering-action. Among other things, the model con-sists of a ’tabular-data’-suspension, an ’Tabular89Bakker’-tire-model, elaboratemass- and inertia-properties, a flat road profile and an open-loop driver. On a1.86 GHz processor laptop, a ten second simulation of this model requires intotal about 150 seconds (using the ’Radau IIa - order 5 stiff’ algorithm with anerror-tolerance of 0.0001). According to Dymola’s ’Messages’-window, about 20seconds is needed for integrating the model equations; the rest of the simulation-time is uses to compile the model-equations needed for integration. Under samecircumstances and with the same computer, SimMechanics requires about 4.5minutes (270 seconds) which is almost a factor 2 in time to simulate a muchless-complicated vehicle model, which indicates that when speed is concerned,Dymola’s ’Vehicle Dynamics Library’ is performing very well, considering thecomplexity of the simulated vehicle-model. Another aspect that has to be men-tioned is that with Dymola, no output variables have to be chosen before simu-lating the model. In the ’Variable Browser’ (see figure C.8) all variables can beplotted afterwards.

Page 51: SimMechanics, MapleSim and Dymola: a first look on three

Chapter 9

Conclusion

As always, new software takes time to get used to. However, the longer youwork with a software package, the clearer it gets. Off-course, due to the lim-ited timespan that was involved for the project and because three multibodypackages had to be learned and examined, only some global aspect were investi-gated. Also, because only very simple multibody models were used to check forsimulation performance, just a small amount of the actual capabilities all of thethree packages was utilized and no significant differences in performance occur.Therefore, it’s hard to draw a conclusion concerning simulation performance justfrom the results obtained from these simple models. Nevertheless, the overall’feel’ of speed and performance when using both MapleSim and Dymola is muchbetter compared to SimMechanics. This can already be seen when just lookingat the startup time: Simulink/SimMechanics takes up to a factor 4 more timecompared to MapleSim or Dymola.

When looking at verification and error handling, we have seen some big dif-ferences. From the error-messages produced by MapleSim it was very hard toidentify the location of the fault that was made because of the mathematicalbased error messages. In SimMechanics and Dymola, most of the times the lo-cation of the fault was specified or became clear from the error-message window.

When numerical accuracy is concerned, no significant differences were observedalthough the error produced by Dymola stayed the highest when we comparedit to those of SimMechanics and Dymola.

A major drawback of the investigated MapleSim multibody package in contraryto SimMechanics and Dymola was the absence of a visualization environment.This made it very hard to verify models and check motion behaviour. Dymoladoes offer an elaborate visualization functionality.

When parametrisation is concerned, all three packages have their own way ofdealing with it. However, the methods used in MapleSim and Dymola couldalso be accomplished in MATLAB/Simulink with some lines of code which, inpractice, turns outs to be the easiest method.

In Dymola, models can be exported to MATLAB/Simulink easily by using the’DymolaBlock’. MapleSim offers a possibility to export a model to C-code.

50

Page 52: SimMechanics, MapleSim and Dymola: a first look on three

CHAPTER 9. CONCLUSION 51

This C-code was almost free from comments which made it hard to understandwithout having knowlege of the actual model.

By investigating a simple closed-loop model, conclusions about how the modelreacts to small deviations in composition were drawn. In both SimMechanicsand Dymola, it was fairly clear from the error-message screens where the faultoccured and what was done wrong. In MapleSim however, is was unclear whatcaused the error which makes it hard to solve the problem.

Finally, the Dymola Vehicle Dynamics Library was investigated. It offers manypre-defined componenents and tyre-models. Also, components are fairly easyto understand and adapted. Moreover, a nice and elaborate visualization func-tionality is available. When the simulation performance is compared to a (muchsimpler) SimMechanics car-model, it can be also concluded that this VehicleDynamics Library also performs well regarding simulation speed.

Summary

In order to summarize the opininon regarding the three multibody packages, atable is made which containts the most important aspects discussed in the pre-ceding chapters. The ’Chapter’-column indicates in which chapter the specificaspect is discussed.

Table 9.1: Summary table

Page 53: SimMechanics, MapleSim and Dymola: a first look on three

CHAPTER 9. CONCLUSION 52

Recommendations

Off-course, because this conclusion is only based on the use of some simplemodels, a more thoroughly investigation would be necessary to investigate allthe functionalities and give a more founded opinion. Nevertheless, an importantaspect of multibody software is verification and error handling and accordingto this, it can be concluded that MapleSim is a less-suitable alternative forSimMechanics. In MapleSim 2 this aspect has not been improved, in contraryto the visualization functionality which is performing very well. The VehicleDynamics Library has proved itself to be a powerful application and thereforewould be of great interest for the TU/e.

When we take into account all the preceding observations, it has to be concludedthat Dymola would be a suitable alternative to SimMechanics and can be usedin cooperation with other applications written or modelled in Simulink andMATLAB.

Page 54: SimMechanics, MapleSim and Dymola: a first look on three

References

[1] I.J.M. Besselink a.o. Introduction to automotive technology lecture notes,2007.

[2] Bram de Kraker & Dick H. van Campen. Mechanical Vibrations. ShakerPublising BV Maastricht, 2001.

[3] W. Kortüm and R.S. Sharp, editors. Multibody computer codes in vehiclesystem dynamics. Swets & Zeitlinger B.V., Amsterdam/Lisse, 1993.

[4] Modelica. Modelica - A Unified Object-Oriented Language for Physical Sys-tems Modeling, 2000.

[5] N. van de Wouw. Multibody dynamics lecture notes, 2007.

53

Page 55: SimMechanics, MapleSim and Dymola: a first look on three

Appendix A

SimMechanics windows

Figure A.1: The car-mass parameters window in SimMechanics

54

Page 56: SimMechanics, MapleSim and Dymola: a first look on three

APPENDIX A. SIMMECHANICS WINDOWS 55

Figure A.2: A scope visualizing the vertical position of the unsprung mass

Page 57: SimMechanics, MapleSim and Dymola: a first look on three

Appendix B

MapleSim windows

Figure B.1: The MapleSim ’parameters’-window

56

Page 58: SimMechanics, MapleSim and Dymola: a first look on three

APPENDIX B. MAPLESIM WINDOWS 57

Figure B.2: The MapleSim ’components’-window

Figure B.3: The MapleSim ’probe-properties’-window

Page 59: SimMechanics, MapleSim and Dymola: a first look on three

APPENDIX B. MAPLESIM WINDOWS 58

Figure B.4: Editing the axis variables

Figure B.5: The MapleSim ’Plot Window’

Page 60: SimMechanics, MapleSim and Dymola: a first look on three

Appendix C

Dymola windows

Figure C.1: Selecting the signal to use

Figure C.2: Dymola’s ’parameter-window’ for the car-body

59

Page 61: SimMechanics, MapleSim and Dymola: a first look on three

APPENDIX C. DYMOLA WINDOWS 60

Figure C.3: Dymola’s ’Component-Browser’

Figure C.4: Adjusting plot characteristics

Page 62: SimMechanics, MapleSim and Dymola: a first look on three

APPENDIX C. DYMOLA WINDOWS 61

Figure C.5: Animation settings for the spring-damper

Page 63: SimMechanics, MapleSim and Dymola: a first look on three

APPENDIX C. DYMOLA WINDOWS 62

Figure C.6: The DymolaBlock GUI

Page 64: SimMechanics, MapleSim and Dymola: a first look on three

APPENDIX C. DYMOLA WINDOWS 63

Figure C.7: Visualization-parameters window of a spring-damper-component

Page 65: SimMechanics, MapleSim and Dymola: a first look on three

APPENDIX C. DYMOLA WINDOWS 64

Figure C.8: A part of the ’Variable Browser’

Page 66: SimMechanics, MapleSim and Dymola: a first look on three

Appendix D

MapleSim C-code

1 /∗ ∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗2 ∗3 ∗ DO NOT EDIT MANUALLY!4 ∗ Automat ica l l y generated by Maple .5 ∗ Created On: Thu May 07 13 :11 :52 2009.6 ∗ Model Name: Main7 ∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗ ∗/89

10 #include <math . h>11 #include <malloc . h>121314151617 /∗ ∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗18 ∗Var iab l e De f i n i t i on f o r simDerOut and simOut :19 ∗20 ∗Output v a r i a b l e ( s ) :21 ∗ MAPLE_y[ 0 ] = Probe1_r_0_1_( t )22 ∗23 ∗ Sta t e v a r i a b l e ( s ) :24 ∗ MAPLE_x[ 0 ] = DFPSubsys1inst_x_RB1( t )25 ∗ MAPLE_x[ 1 ] = DFPSubsys1inst_y_RB1( t )26 ∗ MAPLE_x[ 2 ] = DFPSubsys1inst_z_RB1( t )27 ∗ MAPLE_x[ 3 ] = DFPSubsys1inst_vx_RB1( t )28 ∗ MAPLE_x[ 4 ] = DFPSubsys1inst_vy_RB1( t )29 ∗ MAPLE_x[ 5 ] = DFPSubsys1inst_vz_RB1( t )30 ∗31 ∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗ ∗/32 /∗ I n t e rna l Routines . Do not modify ! ∗/33 void DecompC( long n , double ∗A, long ∗ ip )

65

Page 67: SimMechanics, MapleSim and Dymola: a first look on three

APPENDIX D. MAPLESIM C-CODE 66

34 {35 long i , j , k ,m;36 double t ;3738 ip [ n−1]=1;39 for ( k=0;k<n−1;k++) {40 m=k ;41 for ( i=k+1; i<n ; i++)42 i f ( f abs (A[ i ∗n+k ] )>fabs (A[m∗n+k ] )

) m=i ;43 ip [ k]=m;44 i f ( m!=k ) ip [ n−1]=− ip [ n−1] ;45 t=A[m∗n+k ] ; A[m∗n+k]=A[ ( n+1)∗k ] ; A[ ( n+1)∗

k]= t ;46 i f ( t==0.0 ) { ip [ n−1]=0; return ; }47 t=−1.0/ t ;48 for ( i=k+1; i<n ; i++) A[ i ∗n+k]=A[ i ∗n+k ]∗ t ;49 for ( j=k+1; j<n ; j++) {50 t=A[m∗n+j ] ; A[m∗n+j ]=A[ k∗n+j ] ; A[

k∗n+j ]= t ;51 i f ( t !=0.0 )52 for ( i=k+1; i<n ; i++) A[ i ∗n+

j ]+=A[ i ∗n+k ]∗ t ;53 }54 }55 i f (A[ n∗n−1]==0.0) ip [ n−1]=0;56 }5758 void MultiSolveC ( long n , double ∗A, long ∗ ip , long nb ,

double ∗b)59 {60 long i , j , k ,m;61 double t ;6263 i f ( n>1 ) {64 for ( j =0; j<n−1; j++) {65 m=ip [ j ] ;66 for ( k=0;k<nb ; k++) {67 t=b [m∗nb+k ] ; b [m∗nb+k]=b [

j ∗nb+k ] ; b [ j ∗nb+k]= t ;68 for ( i=j +1; i<n ; i++) b [ i ∗nb

+k]+=A[ i ∗n+j ]∗ t ;69 }70 }71 for ( j=n−1; j >0; j−−) {72 for ( k=0;k<nb ; k++) {73 b [ j ∗nb+k]=b [ j ∗nb+k ] /A[ ( n

+1)∗ j ] ;74 t=−b [ j ∗nb+k ] ;75 for ( i =0; i<=j −1; i++) b [ i ∗

Page 68: SimMechanics, MapleSim and Dymola: a first look on three

APPENDIX D. MAPLESIM C-CODE 67

nb+k]+=A[ i ∗n+j ]∗ t ;76 }77 }78 }79 for ( k=0;k<nb ; k++)80 b [ k]=b [ k ] /A [ 0 ] ;81 }82838485 /∗ Function : simJacobian

=================================================86 ∗ Abs trac t :87 ∗ f ( t , x , J )88 ∗/89 void s imJacobian (double t , double ∗MAPLExx, double ∗Jac ,

long Jac_cn )90 {91 long t i 1 , t i 2 ;9293 for ( t i 1 =1; t i 1 <=4; t i 1++)94 for ( t i 2 =1; t i 2 <=6; t i 2++)95 Jac [ ( t i 1 −1)∗Jac_cn+t i2 −1] = 0 . ;96 Jac [ 2 ] = −1.;97 Jac [1+Jac_cn ] = −1.;98 Jac [5+2∗Jac_cn ] = −1.;99 Jac [4+3∗Jac_cn ] = −1.;

100 }101102103104 /∗ Function : simRes

=================================================105 ∗ Abs trac t :106 ∗ f ( t , x , R)107 ∗/108 void simRes (double t , double ∗MAPLExx, double ∗Resd )109 {110 Resd [ 0 ] = −MAPLExx [ 2 ] ;111 Resd [ 1 ] = −MAPLExx [ 1 ] ;112 Resd [ 2 ] = −MAPLExx [ 5 ] ;113 Resd [ 3 ] = −MAPLExx [ 4 ] ;114 }115116117 /∗ Function : simOut

=================================================118 ∗ Abs trac t :119 ∗ f (N, t , x , xdot )120 ∗/

Page 69: SimMechanics, MapleSim and Dymola: a first look on three

APPENDIX D. MAPLESIM C-CODE 68

121 void simOut ( long N, double t , double ∗MAPLExx, double ∗MAPLEdx)

122 {123 MAPLExx[ 6 ] = MAPLExx [ 0 ] ;124 i f ( N<1 ) {125 return ;126 }127 MAPLEdx[ 0 ] = 0 . ;128 MAPLEdx[ 1 ] = 0 . ;129 MAPLEdx[ 2 ] = 0 . ;130 MAPLEdx[ 3 ] = 0 . ;131 MAPLEdx[ 4 ] = 0 . ;132 MAPLEdx[ 5 ] = 0 . ;133 }134135136 /∗ Function : simDerOut

=================================================137 ∗ Abs trac t :138 ∗ f (N, t , x , xdot )139 ∗/140 void simDerOut ( long N, double t , double ∗MAPLExx, double

∗MAPLEdx)141 {142 MAPLExx[ 6 ] = 0 . ;143 i f ( N<1 ) {144 return ;145 }146 MAPLEdx[ 3 ] = −123456789.∗MAPLExx[ 0 ] / 1 0 0 0 1230 0 . ;147 MAPLEdx[ 4 ] = 0 . ;148 MAPLEdx[ 5 ] = 0 . ;149 MAPLEdx[ 0 ] = MAPLExx [ 3 ] ;150 MAPLEdx[ 1 ] = MAPLExx [ 4 ] ;151 MAPLEdx[ 2 ] = MAPLExx [ 5 ] ;152 }153154155 /∗ Function : s im I n i t i a l i z e

====================================================156 ∗ Abs trac t :157 ∗ Al l o ca t e space .158 ∗/159 void s i m I n i t i a l i z e (double ∗∗MAPLE_y, double ∗∗MAPLE_x,

double ∗∗MAPLE_dx, double ∗∗MAPLE_u, double ∗∗MAPLE_params)

160 {161 ∗MAPLE_x = malloc (6∗ s izeof (double ) ) ;162 ∗MAPLE_dx = mal loc (6∗ s izeof (double ) ) ;163 ∗MAPLE_y = malloc (1∗ s izeof (double ) ) ;164 }

Page 70: SimMechanics, MapleSim and Dymola: a first look on three

APPENDIX D. MAPLESIM C-CODE 69

165166167 /∗ Function : s imGetSizes

====================================================168 ∗ Abs trac t :169 ∗ Return s i z e s o f v e c t o r s .170 ∗/171 void s imGetSizes ( int ∗ size_y , int ∗ size_x , int ∗ size_u ,

int ∗ size_params )172 {173 ∗ s ize_u = 0 ;174 ∗ s ize_x = 6 ;175 ∗ s ize_y = 1 ;176 ∗ size_params = 0 ;177 }178179 /∗ Function : s im In i t i a lCond i t i on s

===========================================180 ∗ Abs trac t :181 ∗ I n i t i a l i z e the s t a t e s .182 ∗/183 void s im In i t i a lCond i t i o n s (double ∗MAPLE_x)184 {185 MAPLE_x[ 0 ] = 0.333445 e1 ;186 MAPLE_x[ 1 ] = 0 .0 e0 ;187 MAPLE_x[ 2 ] = 0 .0 e0 ;188 MAPLE_x[ 3 ] = 0 .0 e0 ;189 MAPLE_x[ 4 ] = 0 .0 e0 ;190 MAPLE_x[ 5 ] = 0 .0 e0 ;191192 }193194 /∗ Function : s imIn i t i a l i z eParame t e r s

========================================195 ∗ Abs trac t :196 ∗ I n i t i a l i z e the parameters .197 ∗/198 void s im In i t i a l i z ePa r ame t e r s (double ∗MAPLE_params)199 {200201 }202203 /∗ Function : simOutputs

=======================================================

204 ∗ Abs trac t :205 ∗ y = f ( t , x , u , p )206 ∗/207 void simOutputs (double ∗MAPLE_y, double t , double ∗

MAPLE_x, double ∗MAPLE_u, double ∗MAPLE_params)

Page 71: SimMechanics, MapleSim and Dymola: a first look on three

APPENDIX D. MAPLESIM C-CODE 70

208 {209 double MAPLE_s [ 7 ] ;210211 MAPLE_s[ 0 ] = MAPLE_x[ 0 ] ;212 MAPLE_s[ 1 ] = MAPLE_x[ 1 ] ;213 MAPLE_s[ 2 ] = MAPLE_x[ 2 ] ;214 MAPLE_s[ 3 ] = MAPLE_x[ 3 ] ;215 MAPLE_s[ 4 ] = MAPLE_x[ 4 ] ;216 MAPLE_s[ 5 ] = MAPLE_x[ 5 ] ;217 MAPLE_s[ 6 ] = MAPLE_y[ 0 ] ;218219 simOut (7 , t , MAPLE_s, MAPLE_dx) ;220221 MAPLE_y[ 0 ] = MAPLE_s [ 6 ] ;222223 }224225226 /∗ Function : s imDer i va t i v e s

=================================================227 ∗ Abs trac t :228 ∗ xdot = g ( t , x , u , p )229 ∗/230 void s imDer iva t ive s (double ∗MAPLE_dx, double t , double ∗

MAPLE_y, double ∗MAPLE_x, double ∗MAPLE_u, double ∗MAPLE_params)

231 {232 double MAPLE_s [ 7 ] ;233234 MAPLE_s[ 0 ] = MAPLE_x[ 0 ] ;235 MAPLE_s[ 1 ] = MAPLE_x[ 1 ] ;236 MAPLE_s[ 2 ] = MAPLE_x[ 2 ] ;237 MAPLE_s[ 3 ] = MAPLE_x[ 3 ] ;238 MAPLE_s[ 4 ] = MAPLE_x[ 4 ] ;239 MAPLE_s[ 5 ] = MAPLE_x[ 5 ] ;240 MAPLE_s[ 6 ] = MAPLE_y[ 0 ] ;241242 simDerOut (7 , t , MAPLE_s, MAPLE_dx) ;243244 }245246247 /∗ Function : simTerminate

====================================================248 ∗ Abs trac t :249 ∗ Free space .250 ∗/251 void simTerminate (double ∗MAPLE_y, double ∗MAPLE_x,

double ∗MAPLE_dx, double ∗MAPLE_u, double ∗MAPLE_params)

Page 72: SimMechanics, MapleSim and Dymola: a first look on three

APPENDIX D. MAPLESIM C-CODE 71

252 {253 f r e e (MAPLE_x) ;254 f r e e (MAPLE_dx) ;255 f r e e (MAPLE_y) ;256 }