Use of the Model Management Library

With the installation of Dymola there is the Model Management library, which allows users to be able to gain data about models and even create and modify models. This can be a very powerful and useful tool, if used correctly. This post will go through a couple of examples and my favorite use of the library.

Abilities within the Library

The functions within the library are divided up into 3 categories:

  • Check – Library quality checking functions, to ensure existence of documentation and descriptions, check class name quality, create regression results and more library maintenance functions
  • Compare – Compare 2 models/packages, in terms of contents, equations and documentation and generate report.
  • Structure – Create, modify, and gain information from classes.

The application and use of the structure functions is the main focus of this blog post.

Creating and Modifying Double Pendulum Example

For this blog post I created a set of steps that will extend and then modify a double pendulum experiment. The set of functions can be used within a function or within a script. The unformatted code is below, but these are the steps, describing each function call:

  1. Create a new package called ModelManagementTests with the description “Package containing models to test modelManagement”
  2. Create a new model called DoublePendulum within the new ModelManagementTests package with the description “Test of the model management on double pendulum model”
  3. Add an extends statement to DoublePendulum which extends from “Modelica.Mechanics.MultiBody.Examples.Elementary.DoublePendulum”
  4. Add a new “Modelica.Mechanics.Rotational.Components.Spring” instance called revolute2Spring to the model, with a description of “Spring applied to revolute 2”
  5. Add diagram placement of revolute2Spring to be {{20,20},{40,40}} so that it can be seen on the diagram layer
  6. Within revolute2, change the parameter useAxisFlange=true
  7. Create a connection between revolute2Spring.flange_b and revolute2.axis
  8. Create a connection between revolute2Spring.flange_a and
  9. Within revolute2Spring, change the parameter c=10
    "Package containing models to test modelManagement",

    "Test of the model management on double pendulum model",


    "Spring applied to revolute 2");






While this is a simple example it utilises a number of different functions within the Model Management Structure folder to perform some basic tasks. The application for this specific example could be looped to create multiple variances of different models. For example, automatically creating multiple versions of vehicles with different loads/spring/damping setups that can then be used in vehicle experiments.

Vehicle Initialisation

Personally, my favourite application of the model management library is using it to improve the ease of setting initialisation variables, building upon last month’s blog post from Theo about dynamic initialisation. Consider vehicle data, like hardpoints, which are defined to produce acceptable geometry (like ride height) for a set vehicle load, commonly when the vehicle is in an unloaded condition. But durability tests require multiple load cases and with a trailer attached. With the different loads and trailers the resting height and angles of the vehicle body and suspension compression will be different each load case. For efficient simulation we want the vehicle and trailer to initialise in a steady state without any time lost to vehicle settling.

To ease development, which would call for renewing the initialisation variables following almost every change to the vehicle, functions were created to automate that process. The function runs an initialisation experiment redeclaring to the chosen vehicle, with the suspension stiffness increased to a point where the deflection would be minimal when loaded. It then reads the results from that experiment to gain the spring force and body position and angles and then, using Model Management, applies those values to the vehicle.

I created a small folder that contains the pendulum example function above and a function to perform a vehicle initialisation test and parameter population. It can be downloaded by following the link below:


Written by: David Briant – Senior Project Engineer

Please get in touch if you have any questions or have got a topic in mind that you would like us to write about. You can submit your questions / topics via: Tech Blog Questions / Topic Suggestion.


Got a question? Just fill in this form and send it to us and we'll get back to you shortly.


© Copyright 2010-2023 Claytex Services Ltd All Rights Reserved

Log in with your credentials

Forgot your details?