The recent Dymola 2023x Refresh 1 release provides a number of new features and improvements. I’m going to talk about a new built-in function which you may have missed, getDependentLibraries, that I’ve been using to check our libraries’ dependencies.
Modelica Library Dependencies
There are many Modelica Libraries available, covering a wide range of applications, that we can use when building our models. When we use a class from another library in our model, we create a dependency on that library and for our model to work correctly that library must also be open in Dymola. If you want to find out more about the benefits of using existing Modelica libraries then take a look at this past blog post, Leveraging Existing Modelica Libraries in Your Simulations.
Typically the dependency information is automatically added to your Modelica library or model when you use a class from another library. This is stored in the text as a uses annotation. Figure 1 highlights the uses annotation in an example library I created, DependencyTests. You can see that the 3 libraries listed in the uses annotation correspond to the models used within my example.

Figure 1 – Uses annotations in the text of an example library.
While the uses annotation tells me which libraries are directly used in my library, they don’t give me the entire dependency picture. If I use a class from a library without a version number, it would not appear in the uses annotation. Also, the uses annotation doesn’t necessarily list all the libraries I would need open in Dymola for my model to simulate, because these libraries in turn are dependent on other libraries that are not listed.
Finding All Your Library’s Dependencies
So this is where the new in-built function getDependentLibraries comes in handy, because it will give me the names of all the libraries I am directly and in-directly dependent on. The function is written in the Dymola command line as shown below.
getDependentLibraries(modelName, dependentModels=false)
Where:
- modelName is the full library or model path string.
- dependentModels can be set to true to list each model used rather than just the libraries, this can be a long list.
When I apply the function to my library example, DependencyTests, it returns the library dependency list shown in Figure 2. As you can see, it contains many more libraries that the uses annotation. Even for this simple example, there are potentially 34 other libraries that are needed for the models in my example to work.

Figure 2 – Library results from getDependentLibraries for the example library in Figure 1.
When I use the getDependentLibraries function with dependentModels set to true (the default is false), it lists 1000’s of classes on which the 2 models in my simple example library are dependent.
Why I Need to Know
Even for my simple example there are a large number of dependencies on other libraries, and if you scale that up for 18 Modelica libraries Claytex release, and their accompanying test libraries, the dependencies then become vast. It is important for me to know what libraries our libraries are dependent on so we can:
- Check our libraries’ uses annotations are correct and complete.
- Ensure all of our libraries potentially effected when modifying our models are open during development, so automatic updates of names and paths are made.
- Know what versions of these dependencies we are compatible with.
- Verify that all our dependencies are available in Dymola so our model works, see Troubleshooting non-model related Dymola failures for some issues that occur when this doesn’t happen.
- Generate our conversion scripts correctly.
- Be certain our libraries are upgraded to new versions of our dependencies using the in-built conversion tool in Dymola, as discussed in Migration to Newer Library Versions.
Try using the new getDependentLibraries function to better understand your own library’s dependencies and intervene to change these dependencies if required.
Written by: Hannah Hammond-Scott – Modelica Project Leader
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.