Emcs Exercise 05 2025
Emcs Exercise 05 2025
This exercise shall encourage you to translate your bond graphs to simulation models and try out the equation-
based approach. There will be no “solutions” to the programming exercises, but you you will be provided with
the model files for the mass-spring-damper system on moodle (see also the short introduction in the lecture
notes). This shall enable you do set up the OpenModelica models also for the other example systems!
OpenModelica is not a topic of the exam, so this sheet is for students interested in the approach.
To get an idea about what type of models Modelica generates, and how the simulations results are stored,
open the OpenModelica Shell and type the commands shown in the screenshot in Fig. 5.1. It is assumed that
the model files of the mass-spring-damper system are located in the directory "e:/".
Figure 1: Screenshot of the OpenModelica Shell with the commands to execute in Exercise 5.1.
a) The command exportDAEtoMatlab generates the Matlab script msd_imatrix.m. What information
is stored in the cell arrays IM, VL, EqStr and OldEqStr?
Remark: Modelica obtains the numerical solution of a model by default after a transformation of the
DAE to an ODE representation. However, also a direct solution of the DAE model with a corresponding
solver is possible, which can reduce the effort of model post-processing1 .
b) Once in Matlab, load the file msd_res.mat with the simulation data. Browse the data structures and
write a Matlab script, which generates a plot that represents the elongation of the spring and the velocity
of the mass over time.
Starting with the example models mass.mo, spring.mo and damper.mo, create a library (a collection of
models) in OpenModelica for the network elements in the examples we have treated so far.
In the remaining exercises, the parameter values for the considered models are not a priori given. Choose
yourself typical parameters values that are physically reasonable and would fit to the considered application.
Do a quick research in the literature/on the web if necessary.
Create a Modelica model QuarterCar.mo using the (sub-)models from your library. When simulating the
quarter car model, the following issues can be interesting:
a) Simulate the system behavior for different road profiles (input velocities). To this end, the corresponding
velocity must be equated with an appropriate time function. Find out in the OpenModelica documen-
tation how this works.
b) How could you import, for example, a velocity profile given in a csv table?
c) Create nonlinear models NLspring.mo and NLdamper.mo for spring and damper with corresponding
characteristics that can be tuned by a set of parameters. You can use, for example, a degressive damper
and a progressive spring model. Search in the literature. Replace the linear models in the quarter car
model and describe differences in the dynamic behavior.
Set up a Modelica model RLCcircuit.mo for the RLC circuit and check its correctness by the matching of the
simulation results with characteristic quantities that can be computed, e.g., the (undamped) eigenfrequency.
Finally, create the Modelica model TwoMassSystem.mo. Excite the system with test inputs like steps in the
input voltage and load torque. Does the system react in the physically meaningful way? Consider the transient
dynamics and the behavior in steady state.
1 See www.openmodelica.org/doc/OpenModelicaUsersGuide/latest/solving.html