Written by: Romain Gillot – Project Engineer
From within Dymola we can export a list of the model parameters and filter them by subsystem.
Let us consider as an example the double pendulum model from the Modelica Standard Library:
Figure 1: Double pendulum example.
We will extract the list of parameters from the xml description of the model. To generate the xml file, we need to export the model as an FMU, to do so, go to the simulation tab and click on the black arrow next to the translate icon and click OK (you need to make sure that the model actually checks in Dymola so you can create the FMU):
Figure 2: Export the model as an FMU.
The xml file will be created in a folder called “~FMUOutput” in your working directory. It is called “modelDescription”.
The next step is to open Excel and to go to the Developer tab. To enable it in case it is not already, click on File, Options and then click on Customize Ribbon. Find Developer in the list and add it.
Figure 3: Add Developer to the list of tabs.
In the developer tab, click on Source and then on XML Maps… on the window that appears. This should look like this:
Figure 4: Ready to import the XML Map.
Now click on Add, then browse to the location where the XML file has been created, select it and click open. Click OK to add the map.
The model description map has now been imported to the Excel file:
Figure 5: Model description map.
We can now scroll down in the map and look for the model variables. Let’s click on ModelVariables and drag and drop the selected part of the map to an empty cell on the Excel sheet.
Now select all the cells that have just been populated and right-click on one of them. Click on XML and then Import… as shown below:
Figure 6: Ready to import the map data.
After clicking Import, browse to the XML file location and once selected, click Import.
The list of parameters and variables has been imported to the Excel file. To only see the parameter list, click on the causality tab on the map and tick “parameters”.
A number of filters are available by just clicking on the arrow of a tab of the map. The parameters are named by their full paths in the model, they have a description (the same as in Dymola), a unit, a value, etc.
If the model is big, the list of parameters will also probably be quite large. If only the parameters relative to a subsystem of the model are of interest, we can filter them out.
To do so, start by adding empty columns to the right of the column “name” (the number of columns to be added depends on the number of layers in the Dymola model, 5 should be enough for most models). Then select the first column of the map (“name”) and go to the Data tab of the excel file and click on Text to Columns. Choose “Delimited” as shown below:
Figure 7: Filter the parameters of one subsystem.
Click next then choose a dot “.” as delimiter and click finish.
Figure 8: Split the path of the parameters.
The path of all the parameters has been split, one layer in the Dymola model corresponds to one column in the Excel file.
If we only want to see the parameters of the damper we can filter them in the first column by ticking only damper:
Figure 9: Filter the parameter list by subsystems.
This trick obviously makes more sense with bigger models where there are a lot of parameters!
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.