Dymola tips and tricks series (IV)

Have you been working with Dymola for a while but still feel that you are not using it as effectively as you could be?  In this series of posts, I’ll share tips and tricks that I have picked up along the way.

Part IV: Getting data in and out of Dymola

No tool is an island. At some point the data you generate in Dymola needs to migrate into a presentation, a report, a research paper, or a database. By learning how to best do that, you will work more efficiently.

Copy a curve

This is a really neat feature. Do you have a simulation result trajectory that you quickly need to get into a PowerPoint presentation or Excel spreadsheet?

Right-click on the curve or on the variable name on top of the graph and select Copy.

In the program where you want to insert your data, simply choose paste to insert the time trajectory for the variable along with variable name in the header:

Load .mat files in Matlab

By default, Dymola saves simulation results in a .mat file in the working directory. This .mat file contains all model variables and can therefore be quite large. The .mat files are binaries, and can be reloaded into the Dymola Simulation view, or imported into another tool that supports the file format, such as Matlab.

If you have tried loading the Dymola-generated .mat file in Matlab using the load command and extracting the data, you have probably found that it wasn’t very easy. The data structure that Dymola creates is not exactly transparent.

But there is a better way to do it. In your Dymola distribution you will find the Matlab functions dymload, dymget, and dymbrowse that load the Dymola-generated .mat files and reshuffle the data into a format that makes sense. 

Save .csv files

.csv files are convenient for many purposes: they are human-readable and can be imported to many tools. Keep in mind that .csv files are not efficient for large data sets.

The following Dymola commands will save a few variables from the simulation result FluidNetworkExample.mat to a .csv file:

n = readTrajectorySize("FluidNetworkExample.mat");

var_names = {"Time", "pipe4.summary.T[1]", "pipe4.summary.T[2]"};




Have you heard of DataAccess? It is a package included in the Modelon Base Library, which makes it available for all Modelon commercial libraries.

DataAccess lets you load model parameters from an .xml file in a straightforward and efficient way. The parameters are loaded from the file at run time, so the .xml file can be modified or even replaced after compilation. The link to the .xml file is also preserved at model export, so that an FMU created from the model will access the .xml data.

To use DataAccess, put a Modelon.DataAccess.XmlFile component into your top-level model, and specify the path to the .xml file.

To use parameters from the .xml file, use a call to the access object:

Do you have tips to share or an issue you would like addressed? Please post a comment so we can spread the knowledge!

Maria Henningsson is a simulation consultant at Modelon working on modeling of thermofluid systems and integration of simulation models into CAE tool chains. She has an MSc in engineering mathematics and a PhD in combustion engine control, both from Lund University. 

2015-04-15 Geting data in and out of Dymola

by Maria Henningsson