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 Twin Activate current version supports the MSL version 3.2.3.
Modelica Compiler and Libraries in Twin Activate
Beyond relying on the powerful semantics of Twin Activate to mix both signal and physical blocks, the application of Modelica blocks within Twin Activate relies upon block libraries and a compiler. The Twin Activate Block libraries are based on the Modelica Standard library and other libraries. The compiler converts the Modelica code into code handled by Twin Activate.
Modelica Compiler and FMU
- Twin 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, Twin 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.
-
From the Palette Browser, select 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.
- On the Ports tab, enter the number of input and output ports for the block, enter a name for each port, then click OK.
- On the Parameters tab, enter the number of parameters for the block. For each parameter, enter a name, value and type, and click OK.
- On the SimFunction tab, enter the simulation function for your block, then click OK.
Importing Modelica Libraries
Import Modelica blocks for use in Twin Activate models.
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.
- Save a desired Modelica library to your local system.
-
From the menu bar, select
.Alternatively, select Create a new library from a Modelica library., and select the option to
-
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 Twin 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.