Debugging a model that doesn’t work as expected can be a tricky task for any model developer. One of the recent additions to Dymola to support your debugging activities is the **plot dependencies** feature. Enabling this feature will allow you to display the dependencies of any variable. This isn’t only helpful when debugging a problematic model, but also for better understanding of the behaviour of your models. In this post I will explain how to use the plot dependencies feature to best effect.

## How Dymola Solves Your Model

Dymola converts the system of differential-algebraic equations to differential equations so it can solve them for the derivatives. It does this using **symbolic manipulation**. This process is illustrated in the diagram below.

Figure 1. Symbolic Manipulation Process

When Dymola performs symbolic manipulation (all in the background) it determines a causality of the variables and equations. An equation may be scalar with one variable, or contain several variables. As Dymola flows through the sequence of equations the unknown variables and derivative are solved using the knowns and previously solved unknown values. So dependent variables are all calculated from unknowns solved earlier in the sequence of equations for the problem.

By seeing what each variable is dependent upon you will be able to better understand the behaviour seen in your model and identify the origins of that behaviour.

## How to Use the Plot Dependencies Feature?

As an example I’m going to investigate the behaviour of the Coupled Clutches demo from the Modelica Standard Library. You can find it in Dymola at File > Demo > Coupled Clutches if you wanted to try it for yourself.

Figure 2. Coupled Clutches Demo

Firstly I need to enable the plot dependence feature. To do this you check the **Provide variable dependencies for plotting** option in the simulation setup before you simulate your model. This setting is the same as using the flag **Advanced.GenerateVariableDependencies =true** in the command line. By default, this flag is set to false.

Enabling this feature automatically stores all variables in the model, including any that are protected.

Figure 3. Simulation Setup

Looking through the results of the coupled clutches model, I see that the acceleration of the inertia J3 has a curious dip around 0.79s. I’m going to use plot dependencies to investigate this behaviour further.

Figure 4. J3 Accel Plot

To view the dependencies for this variable, you can either right-click on the variable in the Variable Browser or on the signal in the plot, and then select the **Plot Dependencies** option from the menu.

Figure 5. Plot Dependencies Menu

This produces a new plot like the one shown below. The plot includes the variable of interest and all its dependencies. The equation of the variable will be shown above the plot.

Figure 6. Plot Dependencies Plot

By default, a maximum of 20 signals will be plotted. If there are more dependencies than this, multiple plots will be opened. The flag **Advanced.DependenciesPerPlot **can be used to alter this number if needed.

By zooming in at 0.79s where the drop in the acceleration occurs, we see that there is a corresponding step change in the Boolean variable mode for clutch 1. We can investigate the reason for this change by plotting the dependencies of clutch1.mode.

Figure 7. Plot Dependencies Plot – Zoomed In – 1

The plot of the clutch1.mode dependencies shows that the mode change corresponds to the clutch angular velocity reaching zero at 0.79s. So the cause of the behaviour of the acceleration of the inertia J3 is clear.

Figure 8. Plot Dependencies Plot – Zoomed In – 2

If the dependency equation is very long, like that for clutch1.mode, double click on it to open the text editor where you can see the entire equation.

Figure 9. Plot Dependencies Plot – Equation Editor

So the next time you need to gain a better understanding of the behaviour of your model try Dymola’s plot dependencies feature to make this task easier.

**By: Hannah Hammond-Scott**