Dymola Basics 11: Checking Your Models

When you’re creating your models in Dymola the checking commands are some of the most valuable tools available to you. I’m going to take a look at these commands which you can use to find any issues in your models as you create them and before you try to simulate them.

Where can I Find the Checking Commands?

The checking commands can be executed while you are working in the Graphics or Text tabs in Dymola, where you will see a Check button in the command ribbon. This is shown in Figure 1 below for Dymola 2023x Refresh 1; information about the latest Dymola version can be found here.

Figure 1: The Check button is in the command ribbon of the Graphics (shown here) and Text tabs in Dymola.

Figure 1: The Check button is in the command ribbon of the Graphics (shown here) and Text tabs in Dymola.

The button has a dropdown menu for the different types of checking commands you can run on the class you currently have open from the Package Browser.

What do the Checking Commands do?

These commands check for:

  • Syntax errors in the Modelica code.
  • References to undefined classes.
  • Consistency of equations.

Also, the syntax is highlighted (i.e. colour coded) when you perform a check.

Normal

The normal check will provide:

  • Errors for any critical issues.
  • Warnings for for non-critical issues that don’t stop the model being simulated.

This is the default check which will be performed if you select the Check button.

Pedantic

The pedantic check will treat all the warnings due to non-compliant Modelica code as errors; including non-critical issues which would not prevent simulation. This helps you to create code which is fully compliant with the Modelica Language Specification. This check will generate warnings for non-recognised annotations.

The Modelica Language Specification can be found on the Modelica Association website here, and Dymola 2023x Refresh 1 is compliant with version 3.6.

With Simulation

The with simulation check includes the associated commands in the check. So the commands included in the model’s annotations are executed and then model simulated with the experiments settings stored in the model.

Style

The style check will see if the class conforms the style guide. This uses the ModelManagement.Check.checkStyle() function by default, but this can be changed using the Advanced.Check.StyleCheckFunction flag. The settings for the Model Management style check function can be customised to suit your needs. A complete guide on this feature of the Model Management library can be seen in section ‘9.4.5 Style checking’ of the Dymola 2023x Refresh 1 Full User Manual.

While the other checking commands report their outcome in the Syntax or Translation logs, the default style check produces a html file which is opened in a pop-up window.

Before You Go

If desired, these checks can also include finding unused parameter which can be useful. To do this, the flag Advanced.Check.WarnAboutUnreferenced must be set to true.

You can decide to use the pedantic check all the time, regardless of which of the checking commands you select from the menu. Thus, forcing you to create fully Modelica Language Specification compliant code. To do this go to the Simulation tab in Dymola and select the Setup button. This will open the Simulation Setup dialog, where you can select the Pedantic mode checking for Modelica semantics option in the translation tab, as highlighted in Figure 2.

Figure 2: Option in the Simulation Setup to enforce pedantic checking.

Figure 2: Option in the Simulation Setup to enforce pedantic checking.

If you like to use hot keys, then you may have spotted in Figure 1 that the normal and pedantic checks have hot key options shown in the menu, F8 and Ctrl + F8 respectively.

I hope this blog post will help you to check your models regularly during development to avoid issues later on. Don’t forget to checkout the other blog posts in our Dymola Basics series.

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

CONTACT US

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

Sending

© Copyright 2010-2024 Claytex Services Ltd All Rights Reserved

Log in with your credentials

Forgot your details?