Modeling with Modelica

Learn about Modeling with Modelica language and Modelica blocks.

Modelica Language

Modelica is an equation-based language that is especially well-suited for modeling the behavior of physical components.

The Modelica language is specified and maintained by the Modelica Association.

For an introduction to Modelica, see the Extended Definitions for Advanced Users and visit www.modelica.org.

Modelica Standard Library

The Modelica Association produces the MSL, Modelica Standard Library, which is an open source library covering many domains. The MSL is a reference library and serves as a basis for all other libraries.

  • MSL versions evolve with the versions of the Modelica Language specification.
  • The Activate current version supports the MSL version 3.2.3.

Modelica Compiler and Libraries in Activate

Beyond relying on the powerful semantics of Activate to mix both signal and physical blocks, the application of Modelica blocks within Activate relies upon block libraries and a compiler. The Activate Block libraries are based on the Modelica Standard library and other libraries. The compiler converts the Modelica code into code handled by Activate.

Modelica Compiler and FMU

  • Activate includes the Modelica Compiler, which takes as input a Modelica block (an assembly of the Modelica code of all the blocks of the model) and produces an FMU (Functional Mock-up Unit).
  • The Modelica compiler is powered by Maplesoft™ .

C/C++ Compiler

The use of Modelica blocks involves the creation of the FMU, which, in turn, requires the use of a C/C++ compiler.

If the error message, Unsupported Visual C++ Target Option, is displayed, Activate is unable to detect a C++ compiler installed on your system. To correct the error, install a supported Microsoft Visual Studio C++ compiler. To view the compiler installed on your system, from the OML command window, enter vssGetCompilerName().

Modelica Custom Block

Define components and Modelica blocks with the MoCustomComponent block.

The Modelica Custom Component block is available for defining an implicit component with Modelica language. The block is fully customizable including its ports, parameters and simulation function. The block lets you leverage any existing Modelica code to create a new component or modify an existing Modelica block.
  1. From the Palette Browser, select Activate > CustomBlocks > MoCustomComponent block. Drag and drop the block into your diagram and double-click it.
    The block dialog appears with tabs to define the Ports, Parameters and SimFunction for the block.
  2. On the Ports tab, enter the number of input and output ports for the block, enter a name for each port, then click OK.
  3. On the Parameters tab, enter the number of parameters for the block. For each parameter, enter a name, value and type, and click OK.
  4. On the SimFunction tab, enter the simulation function for your block, then click OK.

Importing Modelica Libraries

Import Modelica blocks for use in Activate models.

Modelica libraries are available from sources such as www.modelica.org. With the option File > Libraries > Import Modelica Library, Activate can create an Activate library from a Modelica library. Activate imports the components of the Modelica library and exposes them in palettes as Activate blocks. Due to differences in the semantics of Modelica and Activate, the imported blocks should be tested, and edited if needed, before use.
Important:

Imported libraries must be compliant with the MSL 3.2.3. In addition, libraries must be valid Modelica packages, <package>.mo, and include the standard Modelica folder structure.

  1. Save a desired Modelica library to your local system.
  2. From the menu bar, select File > Libraries > Import Modelica Library.
    Alternatively, select File > Libraries > Manager, and select the option to Create a new library from a Modelica library.
  3. From the Library Creator dialog that appears, for Modelica library path, enter the path to the library that you want to import. For Activate library path, enter the path where you want to save the library, and click OK.
    The selected Modelica library is converted into an Activate library and saved to the specified directory. Once imported, the library is available in the Palette Browser and remains so for future sessions unless uninstalled.
    Important: Imported libraries include unique IDs that are included in the block definitions. When sharing a model, you must also share any imported libraries that the model references.