FMU

This block (co)simulates an FMU block.

    FMU

Library

Activate/CoSimulation

Description

The FMU block enables the importing and simulation of an FMU as an intrinsic Twin Activate block. The FMU can be of type Model-Exchange (ME) or Co-Simulation (CS). FMI-1.0, FMI-2.0, and FMI-3.0 are supported. This block automatically detects the FMI version and FMI kind and chooses appropriate methods to simulate them.

Inputs and outputs can be of Real, Integer, Boolean or String data types. FMI-1.0 and FMI-20 support only scalar inputs and outputs, FMI-3.0 support also vector inputs and outputs. The FMU block can also signal an external event to the FMU.

Parameters

FMU_0

NameLabelDescriptionData TypeValid Values

FMUfilename

FMU file name

The full path of the FMU to be imported.

String

NX

Read-only. Number of continuous states

Number of continuous-time states of the FMU. Click the 'Reload' button to automatically populate this field.

Scalar

NZ

Read-only. Number of zero-crossing surfaces

Number of zero-crossing surfaces of the FMU. Click the 'Reload' button to automatically populate this field.

Scalar

nevin

Number of input events

Internal parameter. Number of input event ports of the FMU. Click the 'Reload' button to automatically populate this field.

Number

nevout

Number of output events

Internal parameter. Number of output event ports of the FMU. Click the 'Reload' button to automatically populate this field.

Number

nclocks

Number of clock variables

Number

clocks

Clocks

Number of clock variables in the FMU. Click the 'Reload' button to automatically populate this field.

Structure

clocks/name

Name

Read-only. Name of the clock variable

Cell of strings

clocks/description

Description

Read-only. Description of the clock variable.

Cell of strings

clocks/causality

Causality

Read-only. Type of causality.

Cell of strings

clocks/intervalVariability

Interval Variability

Read-only. Type of clock.

Cell of strings

clocks/intervalDecimal

Interval Decimal

Interval (period of clock for periodic clocks)

clocks/shiftDecimal

Shift Decimal

Shift of offset of the clock for perodic variable.

clocks/resolution

Resolution

Internal parameter. Resolution of the clock.

clocks/intervalCounter

Interval Counter

Internal parameter. Interval counter of the clock

clocks/shiftCounter

Shift Counter

Internal parameter. Shift counter of the clock.

clocks/reference

Reference

Internal parameter.

Cell of scalars

nin

Number of inputs

Number of input ports of the FMU. Click the 'Reload' button to automatically populate this field.

Number

inports

Input ports

Structure

inports/name

Name

Name of the input port. The name is extracted from the FMU file and is not editable.

Cell of strings

inports/description

Description

Description of the input port. The description is extracted from the FMU file and is not editable.

Cell of strings

inports/it

Datatype

Input datatype of the input port. The datatype is extracted from the FMU file and is not editable.

Cell of strings

inports/dodependency

Direct dependency vector for the input

Input-output dependency of the input port (feedthrough). The dependency is extracted from the FMU file, but it is editable. For each input port, a dependency vector is provided which indicates the output ports that depend on the this input port. In this vector zero(0) means no dependency and one(1) means direct dependency of output on input.

Cell of vectors

nout

Number of outputs

Number of output ports of the FMU. Click the 'Reload' button to automatically populate this field.

Number

outports

Output ports

Structure

outports/name

Name

Name of the output port. The name is extracted from the FMU file and is not editable.

Cell of strings

outports/description

Description

Description of the output port. The description is extracted from the FMU file and is not editable.

Cell of strings

outports/ot

Datatype

Output datatype of the output port. The datatype is extracted from the FMU file and is not editable.

Cell of strings

nparam

Number of parameters

Number of editable parameters of the FMU. Click the 'Reload' button to automatically populate this field.

Number

params

Parameters

Structure

params/name

Name

Name of the parameter. The name is extracted from the FMU file and is not editable.

Cell of strings

params/description

Description

Description of the parameter. The description is extracted from the FMU file and is not editable.

Cell of strings

params/tp

Datatype

Parameter datatype of the output port. The datatype is extracted from the FMU file and is not editable.

Cell of strings

params/unit

Unit

Unit of the parameter. The unit is extracted from the FMU file and is not editable.

Cell of strings

params/value

Value

The value of the parameter. The default value is automatically extracted from the FMU and displayed.

params/defvalue

Default value

Default value of the parameter. It’s used in value field.

params/reference

Reference

Internal parameter.

Cell of scalars

nlocals

Number of internal variables

Number

local_names

Additional outputs

This field adds additional output ports to inspect internal FMU variables.

local_types

data types

local_refrs

references

Internal parameter.

FMU_1

NameLabelDescriptionData TypeValid Values

run_as_me

Run as Model Exchange if both FMU types are provided

If the FMU provides both the Model Exchange and Co-Simulation API's, you can select the check box to apply the Model Exchange API, otherwise the Co-Simulation API is applied.

Scalar

0
1

tolerancecontrolled

Provide error tolerance to FMU

Select this check-box to activate tolerance-control of the FMU. If the checkbox is checked, the FMU model is called with a numerical integration scheme where the step size is controlled by using the relative error tolerance for error estimation. In such a case, all numerical algorithms used inside the model operate with an error estimation of an appropriate smaller relative tolerance. If the fixed-step solver is used, this checkbox may be off.

Scalar

0
1

stoptimedefined

Provide final time to FMU

Final time of the model defined in simulaton setup is provided to the FMU.

Scalar

0
1

deleteafteruse

The import block unzips the FMU on each run. Select the check box to delete the unzipped folder after the simulation runs.

Scalar

0
1

inevent

Show FMU input event ports

Select the check box to enable the input event ports of the FMU import block. The FMU import block has two input event ports: External and End. The External event can be activated by any event and puts the FMU (of type ME) into the event iteration mode. The End event puts the block into terminate mode.

Scalar

0
1

outevent

Show FMU output event ports

Select the check box to enable the output event ports of the FMU import block. The FMU import block has two output event ports:Discrete and End. The Discrete event is triggered when a time event is programmed inside the FMU block. The End event is triggered when the FMU requests a termination.

Scalar

0
1

resources

FMU resource location

Location of the resource folder for the FMU. If a location is not specified, the default location is fmu://resources.

String

tempdir

Directory for unpacking the FMU

Specify a folder to unzip the FMU. If a folder is not specified, the FMU is unzipped into a temporary folder.

String

ipc

Run in safe mode

If enabled, the FMU is loaded inside another process. This protects Twin Activate from crashes in the FMU. Simulations run slower in this mode.

Number

0
1

nEnvVar

Number of environment variables

Number of environment variables to pass to FMU.

Number

EnvVars

Environment Variables

Structure

EnvVars/varname

Name

Name of the environment variable to pass to FMU.

Cell of strings

EnvVars/varvalue

Value

Value of the environment variable to pass to FMU.

Cell of strings

FMU_2

NameLabelDescriptionData TypeValid Values

enable_fmulogging

Enable FMU logging

Select the check box to enable the logger.

Number

0
1

simloglevel

FMU interface logging level

Select a logging level for the interface to the FMU block. The levels Info, Warning, and Error are registered.

String

'Nothing'
'Fatal'
'Error'
'Warning'
'Info'
'Verbose'

add_Activate_messages

Add Twin Activate messages

Select the check box to include messages from Twin Activate in the log file.

Scalar

0
1

fmulogging_cats

FMU logging categories (for FMI-2.0 and later)

The FMU can filter log messages. You can enter the required log categories. Log categories should be protected by double quotes and separated by a comma.

String

log_file_name

Log file name (*.log)

The log file name to be created. If this field is left empty, the logger is disabled.

String

csv

Separator character used in .csv file

The separator character in the output .csv file.

String

out_enum_as_int_flag

Print Enums and Booleans as integers in .csv file

Select the check box to activate the Enum values as integers, otherwise the text values are stored.

Scalar

0
1

log_only_outputs

Store only input/output variables

Select the check box to store only input and output variables in the .csv and HDF files to reduce output file volume.

Scalar

0
1

result_file

Result storage file name (*.csv/*.mtsf)

The full path of the output result file. The output file can be either a .csv or HDF file (with extension *.mtsf).

String

FMU_3

NameLabelDescriptionData TypeValid Values

stepevent

Solver mesh-point events (step events)

If activated, when a step event occurs, the value of each variable is stored at that time instant.

Scalar

0
1

stateevent

Zero-crossing events (state events)

If activated, when a state event (zero-crossing event) occurs, the value of each variable is stored at that time instant.

Scalar

0
1

timeevent

Time events

If activated, when a time event occurs, the value of each variable is stored at that time instant.

Scalar

0
1

OutputOn

Every output update

If activated, when the block outputs are updated, the value of each variable is stored at that time instant.

Scalar

0
1

meshpoints

Meshpoints

If activated, the value of each variable is stored at the solver mesh points.

Scalar

0
1

superdensetimes

Super dense time instants

If activated, the value of each variable is stored at the super dense time instants of the discrete events.

Scalar

0
1

FMU_4

NameLabelDescriptionData TypeValid Values

fixedComStepsize

Preferred fixed communication stepsize

FMUs of type Co-Simulation are simulated by performing input and output updates at intervals called communication points. The communication points can be defined by the Twin Activate solvers or constant time. In the latter case, the constant communication interval size is provided here. This option is valid for FMI 2.0.

Scalar

provideDerivative

FMU input interpolation

If activated, the first derivative of inputs is computed using the numerical differentiation method and is given to the FMU/CS.

Scalar

0
1

exploitOutDerivative

FMU output extrapolation order

Defines the order of extrapolation of outputs.

Number

visible

Secondary simulator should be visible

If activated, the FMU/CS is co-simulated interactively.

Scalar

0
1

EnableRollback

Enable rollback

Apply GetFmuState and SetFmuState APIs to solve algebraic loops if the FMU supports these APIs.

Scalar

0
1

EnableDirectDer

Exploit directional derivative

If activated and the FMU provides directional derivative for Cosimulation, directional derivative will be used to compute the Jacobian of the model.

Scalar

0
1

Ports

NameTypeDescriptionIO TypeNumber

Port 1

explicit

output

nout+nlocals

Port 2

explicit

input

nin

Port 3

activation

input

2*inevent+nevin

Port 4

activation

output

2*outevent+nevout

Advanced Properties

NameValueDescription

always active

yes

direct-feedthrough

Depends on block parameters

zero-crossing

Depends on block parameters

mode

no

continuous-time state

Depends on block parameters

discrete-time state

no