FMI model

The FMI model block enables integration of Functional Mock-up Units (Functional Mock-up Interface models) into pSeven workflows.

Introduction

The FMI model block is intended to run FMU simulations within a pSeven workflow. The block maps FMU inputs, outputs, parameters, and local variables to its input and output ports, so that the FMU can be evaluated by pSeven. When FMI model runs, it receives values to input ports, sets FMU inputs and parameters, and executes the simulation, updating FMU’s internal state at each time step. The block collects values of FMU outputs and local variables and, when the simulation finishes, outputs a number of result vectors containing these values for each time step.

Configuration

Usually configuration of a FMI model block requires the following steps:

  • Select a FMI model file on the Configuration tab. The path to the selected file is assigned as a value to Model path port. This value can be easily changed in Run if you make the port a parameter.
  • Build a model tree.
  • Specify the nodes to be mapped to the respective input and output ports.
  • Set options to be used in a simulation.
  • Specify simulation settings.

The FMI model block supports both Co-Simulation and Model Exchange FMUs.

When integrating a Co-Simulation FMU, use the following input ports to specify simulation settings (all values are in seconds):

  • Start time — sets the simulation start time.
  • Stop time — sets the simulation end time.
  • Time step size — sets the simulation time step size.

Note that you have to provide values for model inputs at every time step. For example, if the simulation starts at 0.0 and ends at 10.0 with the step of 0.5, the block will expect a vector of length 20 as a value to each input port corresponding to a model input.

When configuring the block to run a Model Exchange FMU, you are also required to set simulation start time, end time, and time step using the ports described above. In this case you can also add external events to the simulation by sending values to the Time port.

For example, suppose that you are running a 10-second simulation of a model that changes its continuous state at the fifth second due to some event. The details of the block’s configuration could be:

  • Start time: 0.0
  • Stop time: 10.0
  • Time step size: 0.5
  • Time: (0.0, 5.0, 5.0, 8.0).

In this case, you have to provide 4 values for model inputs, and the block will output a vector of length 20 updating the input values at each time step.

Note

If the Time port is empty (no value is set), it means that no events occurred during the simulation and the model remained constant over intervals of time.

Simulation results are output to the ports corresponding to FMU outputs and variables. Each result is a vector containing the sequence of output or variable values, according to simulation time steps. In addition, the sequence of simulation time steps is output as a vector to the Timeline port.

Options


Error handling behavior

The action to perform if the block encounters an error.

Value:stop workflow, output defaults and signal, or output signal only
Default:stop workflow

When set to stop workflow, the block simply reports an error and the workflow interrupts.

If set to output defaults and signal, the block suppresses the error. Output ports in this case send values assigned to them (the defaults), and the done port outputs a False value (the signal). Note that the block automatically assigns values to output ports that are created when you select model tree nodes. These values are empty (zero length) vectors.

The output signal only behavior means to output only the False value to done; nothing is output to other ports.

FMI model.Include initial value

Include initial values of variables and outputs into result vectors.

Value:True (include) or False (do not include)
Default:False

By default, initial values of FMU variables and outputs (the values at \(t_0\)) are not included into result vectors which are output by the block after running the simulation. This option can be used to include initial values to results.

FMI model.External dependency paths

Locations to search for files required by the model, such as external DLLs.

Value:path string
Default:empty string (no dependencies)

If the FMU depends on additional files to run, you can use this option to specify the directories where the block will search for these dependencies.

The value of this option is added to the PATH variable in the block’s environment. Multiple paths can be specified, separated with semicolon (;).

Note

In the Linux version of pSeven this option is not yet supported.

Known Issues

In the Windows version of pSeven, the FMI model block cannot start if the path to the pSeven installation directory contains local language characters. You can still add the block to your workflow and configure it, but running this workflow will result in an error. Unfortunately this error cannot be fixed by reconfiguring the Windows system locale. Currently the only possible workaround is to install pSeven to a path which contains only English characters, as recommended by the pSeven Installation Guide, or to the default location suggested by the pSeven installer.