1
votes

I have created a small Modelica library of my own. The way I have created it is in a single file. But I would like to make it a proper Modelica Library, as in the one with multiple directories for each subpackages.

So this is what i followed. File > New Modelica Class > Specialization - Package > Unchecked Save contents in one file. I copied the entire package code from the single file library, pasted it here and saved it. while doing so, I've noticed that the library lost most of its extends clauses, few models went missing.

Have I followed the correct procedure to create the library or did I do something wrong?

Can anyone point me towards the right direction?

1

1 Answers

3
votes

@MSK, I cannot help you with OpenModelica as I work with Dymola. I did however recently split a single-file library (called package in Modelica) into several files manually. I did this so that the library hierarchy is represented in the file system hierarchy (i.e. several subfolders and .mo files in a library folder). For 35,000 lines of code this took roughly 10 hours. Just follow these steps:

  1. create folder with same name as library
  2. in this folder, create a text file "package.mo"
  3. "package.mo" has to start with the statement
    within ;
    package [name of your package, i.e. the folder name...without the brackets];

  4. now you want to create a subclass within this package. To do this create another folder containing a text file called "package.mo"

  5. start this "package.mo" with
    within [name of your package];
    and declare the model as usual.

  6. continue all the way down your library hierarchy

  7. at the lowest hierarchy level you no longer need to create folders. You can simply create a .mo with the name of the lowest level class. As usual, start this file with
    within [name of your package].[subclass1].[subclass2];

For an example of implementation please refer to the Physiolibrary found at https://www.modelica.org/libraries or the Modelica Standard Library which also uses this structure.