Introduction
The Modelica library allows quickly to build SysML models for simulation by reusing library elements. It provides model components in many domains that are based on standardized interface definitions. The library components are ready to use and shareable between applications. Find all modelica libraries >>
Importing the Modelica Standard Library
The Modelica Standard Library brings the main components and standard component interfaces from many engineering domains. It provides the black-boxes of Modelica blocks that contains only ports and parameters. The Modelica Standard Library components are imported to SysML project as follow:
- All Modelica types have «ModelicaBlock» stereotype applied with a full Modelica type name specified in the Name property.
- Modelica blocks are created as SysML Blocks.
- Modelica parameters are created as SysML Value Properties.
- Modelica connectors are created as SysML Interface Blocks.
- Primitive types are created as Value Types.
- If Modelica connector has property with flow keyword defined, it is created as SysML Flow Property for an Interface Block.
- For Block (defined as Model in Modelica) import and create only ports (no keyword, type is Modelica Connector/SysML InterfaceBlock) and parameters as ValueProperties.
- Units and quantities are mapped to ISO80000 units and quantities.
All modelica libraries depend from the Modelica Standard Library because of references between components. That's why the first thing you nee to do before using Modelica libraries in SysML projects, is to import the Modelica Standard Library.
To import Modelica Standard Library
- Download the Modelica Standard Library and extract it.
- Open a project in which you want to use the Modelica library components.
- In the top-left corner of the modeling tool, click the File > Import From > Modelica Library.
- Select the ModelicaStandardLibrary > Modelica folder from your file system.
Click Import.
The Modelica Standard Library is imported. See the following figure. All packages with their structure is created in the Containment tree and types are placed in corresponding packages. Note, that file names may do not match with the element names and the file structure may do not correspond to the location in the directory. The package structure is the same as Modelica package structure.In order to to avoid the import of Modelica Standard Library in each project, you can save it as a project and reuse in other projects. For this, do the following:
Using Modelica libraries
Let's say we need to use OpenHydraulics modelica library components in a project. Both Modelica Standard Library and OpenHydraulics library must be imported since some components from OpenHydraulics library have references to standard library.
To use the Modelica libraries in SysML project
- Create new or open existing SysML project.
- Import the Modelica Standard Library. Follow the procedure above >>
- Download the OpenHydraulics library and extract it.
- In the top-left corner of the modeling tool, click the File > Import From > Modelica Library.
- Select the OpenHydraulics folder from your file system.
- Click Import.
The OpenHydraulics library is imported. The figure below demonstrates the reference between components from OpenHydraulics and Modelica Standard Libraries: the RealOuput type of a Proxy Port y which is in OpenHydraulics library references to Modelica Standard Library.
You can create model by dragging Modelica library elements directly on diagram pane. As shown in the figure below, the simple schema is created by dragging Capacitor and Resistor Blocks on IBD diagram pane and displaying all their ports. To complete schema creation, you need to type names c and r for a Part Properties and connect ports.
The figure below shows exported model to Modelica file which already contains references to the Modelica library components.