Marine systems simulation
|
The FhSim FMU (Functional Mock-up Unit) tool makes it possible to export an FhSim model as a stand-alone FMU, see https://fmi-standard.org/. In particular, you can define a set of SimObjects in an FhSim configuration file and export the model, which then bundles necessary libraries and resources in an FMU. Currently, the exported FMU implements FMI 2.0 standard.
FhFmuExport
is the program that exports an FhSim model file as a stand-alone FMU.
FhFmuExport
is a tool to pack an fhsim model file into an FMU with the required binaries to run the model in an FMU Co-Simulation environment. An FMU is a collection of binaries and resources needed to execute a simulation and communicate over a predefined interface. The folder hierarchy of an FMU is as follows:
There is no requirement for a complete set of binaries as long as binaries for the platform in use is present. Missing binaries will only influence the ability to exchange FMUs with users of different platforms. This tool only export binaries for the platform it was compiled for. Note that we only actively maintain the 64 bit version of FhSim.
The tool parses the FhSim input file and collects a list of all dynamic libraries used (in the LibName attribute of the Lib elements in the input file). The tool creates the folder structure for the FMU and creates an installation directory for FhSim, which includes the base executables and libraries for simulation and visualization. Only the SimObject libraries being used are copied into the SimObjects
library folder.
The tool then collects all SimObjects of type ExternalLinkStandard
used for data exchange during simulation. The input ports
(input to object, output of FhSim) and output ports
(output of object, input to FhSim) are mapped to FMU valuerefs fmiReal. The mapping between the FMU valueref and fhsim ‘'object’:'port'is stored in the file
iomapping.xmland is used by the FhSim Co-Simulation implementation
fhFMUDll` and is found in the FMU resources folder.
The FhSim model file is stored as model.xml
in the FMU resources folder, and the appropriate FMU modelDescription.xml
file is written to the FMU folder hierarchy.
Finally, the tool uses the zip command to compress the folder into an FMU (zipped archive with .fmu extension). If no zip command is available, the tool exits and asks the user to create the archive (and thus the FMU) manually.
The table below provides a short description of available command line options for FhFmuExport
.
Program options | Description |
---|---|
--input-file | The FhSim input file defining the model to export as an FMU |
--author-name | The author of the FMU, default: SINTEF |
--description | Description of the FMU, default: Model exported from FhSim with FhFmuExport |
--model-name | The name of the FMU, default: fhsimexport |
--include-license-file | Path to license file to include in the FMU |
--add-dir-to-resources | Copy a directory/directories to the FMU resource folder to make it available for the FMU |
--guess-output-interface | Point to a previously generated fhsim output file to make outputs for the FMU. A new ExternalLinkStandard object is created for outputs and the ports in the output file are connected to the output. Note this requries that only port outputs are used in the example output file, no state outputs are allowed. Default: disabled |
- | Option flags |
--guess-input-interface | Use constant valued source ports (example: "0,0,1") as input to the FMU. A new ExternalLinkStandard object created for input to the FMU and connected to the previously constant ports. Initial values are preserved. Default value 'false'. |
--autocopy | Auto copy files and folder referenced in the FhSim model attributes except those located in 'resources'. It will rewrite references in the FMU fhsim model file to point to the bundled files and directories |
--debug | Build the FMU from debug binaries, useful for debugging in single threaded mode in Common Simulation Platform. Default value 'false' |
--help | Display help menu |
To print a help message type: FhFmuExport --help
and you will get:
fhFMUDll
must come from a configuration with visualization. A functional procedure is thus to unzip a playpen with visualization enabled into a non-visualization playpen.Suppose you have created an FhSim configure file awesomeness.xml
and want to export an FMU for this model. You have a working FhSim installation (also known as FhSim playpen) located at C:\Users\john\fhsim_awesome\playpen\bin
. This installation is FhSim with visualization, where your license.lic
file is located in the bin
folder. The following commands will create an FMU:
This will produce a folder awesomeness
and – if you have zip
CLI tool – awesomeness.fmu
in bin/
. Note that if SimObject libraries referenced in awesomeness.xml
require additional libraries beyond those required by FhSim, you need to manually package them in the awesomeness
folder and compress it into an FMU yourself. Tip: .fmu
is really a .zip
.
You can use an FMU simulation engine to run your exported FhSim FMU awesomeness. We recommend Open Simulation Platform Software. For instance, you can use cosim
to run awesomeness.fmu
.
proxyfmu
in the source
attribute for each afflicted Simulator, see below.Go ahead an create a OspSystemStructure.xml
next to your awesomeness.fmu
with the following content:
Now, run the simulation scenario for 10 seconds: