A Primer for Creating and Licensing MOE Files in Dymola

Dymola (Dynamic Modeling Laboratory) is a powerful modeling and simulation environment for Modelica-based system modeling. When developing libraries or distributing models, you may need to create and license MOE files to control access to your intellectual property. Creating and licensing MOE files in Dymola is quite flexible yet can be done in a relatively straightforward manner. Information regarding creating and licensing MOE Files in Dymola is contained in section 9.3 of the Dymola user’s manual. Information can also be found in section 18.9 of the Modelica Language Specification. This blog post is intended to be a high-level summary of what is contained in those documents. A previous post may also be of interest as it covers some pertinent information on concealment options within a generated MOE file.

What is an MOE File?

An MOE (Modelica Encrypted) file is an encrypted file that protects your Modelica code while still allowing other users to simulate and integrate your models in their own Dymola models. This approach ensures that you can share functionality without exposing proprietary source code.

Creating an MOE File

To create an MOE file, you first need a viable Modelica model or package. When ready to encrypt your package, within Dymola, you can navigate to File → Save → Encrypted File From there you will be asked to provide a name and location for the *.moe file to be created. Then you simply click ‘save’ and the file is created!

During this MOE saving process, Dymola references data contained in the annotation for that model / package. Here is an example of such an annotation:

  annotation (
    preferredView="info",
    Protection(
      Library={"MyLibrary"},
      License(libraryKey="abcsand123s", licenseFile="MyLibraryAuthorization.moe"),
      showDiagram=false,
      showText=false,
      allowDuplicate=false,
      nestedShowDiagram=true,
      nestedShowText=true,
      nestedAllowDuplicate=true,
      showVariables=true,
      showDiagnostics=true,
      showStatistics=true,
      showFlat=false,
      showDocumentation=true),
    version="2025.1",
    versionBuild=1,
    uses(
      Modelica(version="4.0.0"),
      Claytex(version="2025.1"),
      Suspensions(version="2025.1")),
    Icon(graphics={Bitmap(extent={{-100,-100},{100,100}}, fileName="modelica://MyLibrary/Resources/Images/MyIcon.png")}),
    Documentation(revisions="<html>
<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\"><tr>
<td><p><img src=\"modelica://MyLibrary/Resources/Images/MyIcon.png\"/>&nbsp;&nbsp;&nbsp;</p></td>
<td><p><br><b>Copyright &copy; 2025, My Company Name</b></p></td>
</tr>
</table>
</html>"));

While I’m not going to get into all of the specifics of the individual items, the output is a MyLibrary.moe file that can be distributed like any other Modelica package but is not editable and may have some hidden or suppressed features.

Licensing the MOE File

Licensing ensures only authorized users can access and run your encrypted models. In the annotation example above, a ‘libraryKey’ was established. This ‘libraryKey’ is what allows you to generate a license file which will coincide with the moe file you generated and allow a customer to load / use your library. It is important to note here that there is more than one mechanism through which your models can be encrypted. For the sake of simplicity, I will cover the method covered in the Dymola user manual section 9.3.7. Below is an example of an authorization package which can be used to generate licenses for the library with the annotation above.

package MyLibraryAuthorization "License generation library"

  annotation (
    __Dymola_Protection(hideFromBrowser=false),
    Authorization(
      libraryKey="abcsand123s",
      licensor="My Company Name",
      license={License(licensee="My Customer, Bob Smith", id={"mac:aa3777a418c9"}, expirationDate="2025-12-31")}));

end MyLibraryAuthorization;

From within the MyLibraryAuthorization library, the author should again navigate to File → Save → Encrypted File to create the license file MyLibraryAuthorization.moe. This license file can then be provided to the end user (in our case Bob Smith) along with the encrypted library. To use to the encrypted library, the user will need to place the license file in the same directory alongside the encrypted library. When the user loads the encrypted library (MyLibrary.moe) into Dymola, the adjoining license file will also be detected and allow the user to load and use the encrypted library.

Closing

While creating and licensing MOE Files in Dymola can be very granular and quite complex, it can still be achieved in a relatively straightforward manner. MOE files help model developers protect proprietary models while still enabling collaboration and deployment. This mechanism is widely used for distributing commercial Modelica libraries in a secure and professional way. Hopefully this blog post starts to help you better understand what it takes to make and distribute your own MOE files!

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.

CONTACT US

Got a question? Just fill in this form and send it to us and we'll get back to you shortly.

Sending

© Copyright 2010-2025 Claytex Services Ltd All Rights Reserved

Log in with your credentials

Forgot your details?