Preserving the Dymola Translation Log

Why save the translation log?

Running simulations in batches can be useful for a number of reasons. Many times, the most convenient way to do that is to create a function that simulates a few models consecutively. One good example of a use case is when running a complete set of simulations for calibration purposes.  Alternatively, a batch of simulations could be run to quantify the effect of a component modeling change on the structure of models in which it is used. In times like this it is often desired to capture relevant data and statistics about each of model structure. These data are reported via the translation log.

While Dymola automatically generates a results, build, and simulation log for each simulation, the translation log only appears (fleetingly if we asked for a simulation) in the Translation tab of the Messages window. The information in this window is overwritten by each successive translation process which is a far from an ideal scenario. It is even less ideal when the simulation batch is run specifically to identify changes which are reported via the translation log, making it an almost impossible task to manually capture all of the required data.

Typical translation log as displayed in the Messages window of the Dymola GUI, detailing information pertinent to understanding the model structure.

Figure 1: Typical translation log as displayed in the Messages window of the Dymola GUI, detailing information pertinent to understanding the model structure.

With a couple of lines of code, individual translation logs can be saved. This includes models run from a function, meaning important data contained within these logs can be preserved and analyzed later. This is particularly useful in debugging specific simulation failures in an array of experiments, or quantifying the structural effects of specific model changes across a plethora of simulation scenarios.

What information does the translation log specifically contain?

Generally speaking, there are 3 separate data logs output from a Dymola simulation:

  • Translation Log – Information regarding the structure of the model
  • Simulation Log – Information about how the model has performed during simulation
  • Build Log – Information detailing the compilation process undertaken in creating the Dymosim.exe executable

Both the simulation log and the build log are available in text file format; dslog.txt and the buildlog.txt files respectively are generated for each simulation within the Dymola working directory. The translation log however, only appears within the Simulation tab of the Messages window. Since no file is generated, the user has needed to manually copy and paste the information. This is not only a laborious task, it is also difficult to undertake when running a batch of simulations.

Important aspects of the translation log include a run down of the states selected in the model, numerical statistics regarding the model non-linear/linear systems and information regarding other model settings, such as decoupling. Beyond this, other important information is provided, such as the list of warnings generated by the model, which often provide clues as to potential issues within the model. Error messages associated with simulation failure are also useful, generally indicating the problem causing the simulation to fail.

How is the translation log saved from function?

Two commands are required to save the log; one is an advanced flag, to tell Dymola to mirror the translation log text to the command line history. The other is a save command, complete with filename, to save the contents of the command line history.

So, within the algorithm section of a function, set the following flag. (Alternatively, this flag can be set manually prior to running a single instance of an experiment from the Simulation window.)


With this set, the simulation can be run by various commands, summarized here. Once run, the translation statistics will appear in the commands window:

An example of the translation log, when output to the Commands window.

Figure 2: An example of the translation log, when output to the Commands window.

Now, all that is required is to save the information within the Commands window. The following command will produce a text file containing this information with the specified filename, logically placing the file in Dymola’s working directory. Any filename could be used, provided it is a string parameter containing the file extension, .txt.


The result will be a text file which should look something like this:

Captured contents following the simulation.

Figure 3: Captured contents following the simulation.

One more quick tip. The command clearlog(); is going to be useful. This clears the current contents of the Commands log. Clearing the contents will prevent any older contents of the Commands log from being captured in the file.

For a practical demonstration, the function is attached. Please note that the file was renamed to runMySim.txt to make wordpress comfortable that it didn’t contain a virus… #eyeroll. This file provides the code to run the Modelica Standard Library “Double pendulum” experiment in Dymola and save the translation log.

Nate Horn – Vice President 

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-2019 Claytex Services Ltd All Rights Reserved. | Designed by CMA Marketing

Log in with your credentials

Forgot your details?