Saving a Modelica library

March 5th, 2011 by Garron Fish

The Modelica language specification defines two ways that a library can be saved.  The complete library can be saved as a single Modelica file or it can be mapped to a directory heirarchy.

In Dymola this choice is made when creating a new package by the checkbox at the bottom of the dialog, see below.  If you later decide you want to change how the package is being stored then select the package, go to the Edit menu and select the Attributes option.

Dymola new package dialog

When choosing to save the package in one file, a single Modelica model file will be created that contains all the classes defined in this package.  Whilst this makes the package easy to copy around between computers it is not really suitable for use with revision control systems.

When choosing to save the package as a directory structure what you will get is a directory structure where each class is stored as a separate Modelica model file.  This approach is very good for use with revision control systems because the revision of each individual class within the library can be managed independently.  An example of the structure you might get is shown below for the Modelica Standard Library:

Modelica package as a directory