Import by a Command
You can import a model in an FMU format using a command.
Notes:
- Except from selecting the FMU itself, the selections you can do corresponds
almost to what you can select by preferences. The differences are:
- When importing an FMU, you can also select to specify exactly what
variables you want to include in the FMU.
- When importing an FMU, you can also select if to be prompted before
replacing an existing Modelica model when importing the FMU.
- The minimal number to activate stacked connectors can only be
specified in this preference dialog.
- For the preferences dialog here, and the corresponding settings in the dialog when
importing an FMU, if you change any preference or setting, it is changed in
both dialogs.
- The settings corresponding to the preferences are kept between
sessions.
- You can select preferences from
, the FMI tab. See FMI.
-
From the Behavior Authoring section of the action bar, click Import FMU
.
The Import FMU dialog box appears.
-
Browse to select your FMU file and click Open.
The Import FMU dialog box appears.
The name of the selected FMU is prefilled in the first field.
- Optional:
To select another FMU, click Browse and browse for another
FMU.
-
Select Preferred type as any of:
- Model exchange
- Co-simulation
-
Select what options to activate:
-
To have a warning before replacing an existing Modelica model, activate
Prompt before replacing an existing Modelica model.
-
To include a file containing the variable names in the FMU, activate
Translate value reference to variable name
This is useful for debugging, but might affect the
performance. With this preference selected, value references are mapped to
variable names in the FMU log messages.
-
To present the variables of the imported FMU in a hierarchical structure using
records declarations, activate Structured declaration of
variables.
This is useful when you, for example, want to change
parameter values in the variable browser after a simulation. Note:
To be able to
use this option, the attribute variableNamingConvention in the
model description file of the FMU to be imported must be specified to
variableNamingConvention="structured" .
-
To select the target package to import the FMU to, you can do any of the
following:
The selected package appears in the field. Note:
If you donĀ“t select any
package, the FMU is imported to the root level of the Package
Browser.
-
To select what variables to expose in the imported FMU, do any of the
following:
- To expose all variables in the imported FMU, select All
variables, then go to to Step 9.
- To expose only parameters, inputs, and outputs, select Black box
(parameters, inputs, outputs), then go to Step 9.
- To specify in detail what variables to expose, click These
variables. See next step for selection.
-
To specify what variables to expose when you have selected These
variables in the previous step, click Select to
display a dialog for selection.
In the dialog, by default, all variables are selected to be exposed.
-
In the left part of the dialog, select the variables to hide.
You can:
- Search for variables by typing in the first field.
- Expand and collapse nodes in the tree individually, or all by clicking
Expand All or Collapse
All.
- Multiselect variables individually, or all by clicking Select
All or Select None.
-
Click Hide to hide the selected variables.
-
When you have finalized the selection, click OK.
The variables to expose are listed in the field under These
variables in the previous dialog box.
-
Click OK to import your .fmu file
containing the corresponding resources within the Dymola Behavior Modeling
app.
A progress bar appears. Note:
As the .fmu file is
checked before import, it must be correct for a successful import.
The Message Reporting window
appears to let you know the import result.
-
Save.
Import by Scripting
You can import a model in FMU format by scripting.
Note:
The binary library files from any previous import are replaced when calling the below
scripting function. For this reason, translation of previously imported FMU models
are not guaranteed to work any longer (in the unlikely event of a name clash).
Before you begin: Some preferences
apply also when using scripting (the rest can be specified in the scripting
function):
- Translate
value reference to variable name
- Structured
declaration of variables.
These preferences can be changed from
, the
FMI tab. See
FMI.
The preferences are kept between sessions.
-
Open the
Modelica Scripting window, see
Create and Execute a Script.
-
Use the scripting function
importFMU(fileName,
includeAllVariables, integrate, promptReplacement, packageName,
includeVariables) .
-
Set
fileName to the name of the FMU file to be
imported, including the path, e. g.
"E:/Import/MyFMUFile.fmu"
-
Set
includeAllVariables to false
if only inputs, outputs, and parameters are to be exposed
(black-box import).
By default, this parameter is true, exposing all variables.
-
Set
integrate to false if the
co-simulation part of the FMU is to be used.
By default, this parameter is true, meaning that the model
exchange part of the FMU is used.
Note:
This parameter is only relevant for FMU models
supporting both model exchange and co-simulation. Otherwise this
parameter is ignored.
-
Set
promptReplacement to true if
you want to be prompted before replacement of any existing Modelica
model from a previous import.
By default, this
parameter is false.
-
Set
packageName to the name of the package where
the FMU is to be inserted, for example "MyLib" .
By default, this parameter is an empty string, meaning that the
FMU is inserted in the top level of the Package
Browser.
-
To specify in detail what variables are to be exposed, you can
enter them using the parameter
includeVariables .
By default, this parameter is an empty array, meaning that the
parameter includeAllVariables specifies what
variables to expose (see this parameter above).
-
Execute the script, see
Create and Execute a Script.
When the script is executed:
- A progress bar appears.
- The Message
Reporting window appears to let you know
the import result.
- If the import is
successful, the .fmu file containing the
corresponding resources is imported to the Dymola Behavior Modeling
app.
Note:
As the .fmu file is checked before import, it
must be correct for a successful import.
-
Save.
Set the Macro Step Size of an Imported and Instantiated
Co-simulation FMU
If you have imported a co-simulation FMU, you can specify the macro step size of the
instantiated FMU.
Before you begin: Import and instantiate a co-simulation FMU.
-
Right-click the FMU in the diagram or
Component Browser and select
Edit Component Parameters.
-
Select the
FMI tab.
-
Type the value in the
fmi_CommunicationStepSize: box.
The default value is
(fmi_StopTime - fmi_Starttime)/500 .
-
Click
OK.
|