FromModelica Function

Use the FromModelica function to define parameter values of Activate Modelica components.

The FromModelica function gives you access to Modelica resources, which you can use to define the parameter values of Activate Modelica components. These resources include both data and functions available in Modelica libraries, and other Activate Modelica components present in the model.

The usage is with one, two or three arguments:
FromModelica(path [,opt1 [, opt2])
The argument path, of type string, can designate either an entity in a Modelica library or a component in the model. The optional arguments opt1 and opt2 can be a string, representing a name, specifying an entity (an element of a record, an element of a package, a component parameter…), a struct, defining a modifier, or a cell containing the arguments of a function call. A struct is also used in case of function-calls with named arguments. See the Appendix for a detailed explanation.

Retrieving a Value from a Library

In case of Modelica library access, path is an OML string designating a library element following the usual Modelica syntax, where the hierarchy is specified using “dot” notation, with “Modelica” as root in case of MSL for example. The path can designate a constant, a record, a function, a package, etc. For example,

FromModelica(‘Modelica.Constants.T_zero’)
can be used to retrieve the value of the absolute zero temperature in Centigrade from the package Modelica Constants. The following is an example where a Modelica record is retrieved:
FromModelica('Modelica.Magnetic.FluxTubes.Material.HysteresisEverettParameter.M330_50A')
M330_50A is an element of Package Modelica.Magnetic.FluxTubes.Material.HysteresisEverettParameter. An alternative to the above way to access the record, is the following:
FromModelica('Modelica.Magnetic.FluxTubes.Material.HysteresisEverettParameter’,’M330_50A')
The name of the record here is provided as a second argument to the function FromModelica. The advantage of using this construction is that the name of the record can be parameterized using an OML variable, as shown next:
FromModelica('Modelica.Magnetic.FluxTubes.Material.HysteresisEverettParameter’, rec)
where rec is an OML string defined in the workspace of the diagram containing the component, specifying the record selected in the package. For example, rec can be conditionally defined in the diagram context as

if cond, rec=’M330_50A’, else rec=’M270_50A’; end

The optional arguments can also be used to define modifiers. The structure field names correspond to the modified entity names, for example for modifying record elements, as shown in the following example:

FromModelica('Modelica.Magnetic.FundamentalWave.Types','SalientReluctance',struct('d',12, 'q',14))
The modifier here is specified by an optional argument of type OML structure. The argument struct(‘d’,12,’q’,14) correspond to the Modelica modification (q=12, q=14). Note that the new values of d and q record elements can be parameterized using OML expressions.

Function calls in Modelica can be done both with and without named arguments. Named arguments can be considered specific modifiers and can be specified using OML as indicated previously. The positional argument passing is supported using a cell instead of a struct.

The following example shows how the symmetricOrientation function can be used with argument m=3:

FromModelica('Modelica.Electrical.MultiPhase.Functions.symmetricOrientation’,struct(‘m’,3))
Alternatively, since m is the first (and unique) argument of the symmetricOrientation function, the same result is obtained by
FromModelica('Modelica.Electrical.MultiPhase.Functions.symmetricOrientation’, {3})
In case the function has multiple arguments, the cell includes all the arguments in order, for example:
FromModelica('Modelica.Electrical.MultiPhase.Functions.activePower’, {v,i})