You can define user-defined unit type.
This scenario shows how to define, in your library, a class with a
Type class type and a basic type extends
(Real, for example).
The following Modelica code defines such a type (in this example,
the 'bar' unit is chosen as unit):
type MyPressure = Real (unit="bar");
Before you begin: Open the library where the class is to be used, for example
MyUnitLib.
-
From the
Behavior Authoring section of the
action bar,
click
Modelica Editor
.
The
Modelica Editor dialog box appears.
-
In the
Modelica Editor dialog box, enter the code
line:
type MyPressure = Real (unit="bar");
-
Click
OK.
In most other cases you can use the command
New Modelica Class
to create a new type, but in this case you can use the
Modelica Editor to get a simpler code
structure.
A user-defined unit type MyPressure with the unit "bar" is
created.