Creating and Exporting Co-Simulation FMU Models

Use the co-simulation FMU functionality to export a Twin Builder design in a Subsheet as an FMU. You can import FMUs with any tool that supports FMI co-simulation version 2.0. For the simulation, the importing tool is the primary solver, while the Twin Builder solver in stand-alone mode is the secondary solver.

Follow these steps to create and export an FMU model using the schematic editor.

  1. Open a Twin builder design.
  2. Open the top-level design in the schematic editor.
    Note:

    Transient (TR) analysis settings (Hmin, Hmax, and Tend) and the TR options (integration formula, tolerances, and so on) from this top level will be applied when the co-simulation is running. Make sure these values are appropriate for the co-simulation run before compiling the FMU.

  3. Select the desired subcircuit design instance on the schematic that you want to compile as an FMU component.
  4. Right-click the selected subcircuit instance and select Compile as Co-Simulation FMU. The Compile as Co-Simulation FMU dialog box appears.
  5. In the Compile as Co-Simulation FMU dialog box, enter the name of the FMU as the model name (the default name is FMUModel).
  6. Specify whether the exported FMU should check out a runtime license at execution time.

    Note:

    If the FMU is exported as an unlicensed FMU, a separate export license is required. The runtime licenses for the licensed FMU or the export licenses must be purchased separately.

  7. Select the dependent data and binary files to include in the FMU.
    Note:

    When creating an FMU for co-simulation, Twin Builder includes all necessary dependent binary and data files in the FMU's resource folder. This includes binaries for the solver as well as binaries and data files for C-Models or sub-FMU models.

    1. Select AutoDetect if the subsheet to compile as a co-simulation FMU contains only models from system libraries, C-Models, FMU models, or any other model definitions that do not load binaries or data files manually.
    2. Select Complete if the subsheet to compile as a co-simulation FMU contains user-defined models that manually load any binaries or data files from the userlib or personallib folders. By default, all files from the userlib and personallib folders are included in the FMU. Instead of including the files from the standard userlib and personallib folders in the FMU, you can specify alternate locations in a configuration file. Include these lines:

      [Windows]

      UseAltLibDirs=<Yes/No>

      AltUserLibDir=<Alternate UserLib folder for Co-Simulation>

      AltPersLibDir=<Alternate PersonalLib folder for Co-Simulation>

      Warning:

      If you need to share the FMU with someone else when selecting this option, make sure the library folders do not contain any files with sensitive data such as intellectual property. In such situations, either remove those files, or configure an alternate userlib and personallib folders without any sensitive data.

  8. Click Compile to compile the FMU model. The model is then added to the project Definitions.

  9. Under the project Definitions > Models, right-click the compiled model and select Export as FMU to export it to a desired location.

Creating Cross-Platform Co-Simulation FMUs

For the creation and simulation of cross-platform (Windows64/Linux64) co-simulation FMUs, download the Twin Builder Linux Redistributable package from the Download area in the Ansys Customer Portal. Select the release version accordingly to your Twin Builder release version and the Linux x64 operating system. The package can be found under the Add-On Packages section of the page.

After downloading and extracting the package, follow the provided documentation for a comprehensive guideline on how to create a Linux-compatible co-simulation FMU, as well as how to simulate it on a Linux environment.

  1. In the Compile as Co-Simulation FMU dialog box, set Include Linux Files to Yes.

  2. Specify the location where you installed the downloaded Linux package in Linux Solver Folder.

  3. If applicable, specify the locations for the Linux versions of model DLLs of PersonalLib and UserLib in the fields for Linux PersonalLib Folder and Linux UserLib Folder.

Component Support

Not all the components in a Subsheet can be supported in the exported FMU. Mainly VHDL models, co-simulation components, and dynamic components that need to connect/simulate with other Ansys Electronics Desktop products before launching Twin Builder simulation are not supported. The following table provides the details about component support for Windows and Linux platforms.

Component type Windows support Linux support Remarks
       
Internal elements Yes Yes  
SML models Yes Yes All SML models including generated SML models such as state-space models, Maxell Equivalent Circuit (ECE model), Ansys Mechanical, Icepak, PExprt Static component, Fluent LTI components are supported.
VHDL No No  
C-Models Yes Yes For user-defined models, dependencies should be placed in appropriate directories.
FMU Yes Yes For Linux, FMU must be cross-platform (support both Windows and Linux).
Modelica Yes No For Linux, Modelica model must be compiled as a cross platform FMU.
Co-simulation components No No Components such as Simulink co-simulation, Maxwell transient co-simulation, Fluent, and RBD are not supported.
Dynamic components No No Components such as HFSS, Q3D, SIWave, and Maxwell Magnetostatic, Electrostatic and Eddy Current are not supported.
Twin Builder ROM components Yes Yes Visualization is not supported for ROMs.
Data connector No No  
Python component No No  
Excitation component No No  
Note:

Even though Simulink co-simulation is not supported, Simulink Coder generated Twin Builder C-models are supported.

Exporting a Subsheet Containing any Modelica Model as a Linux Compatible Co-Simulation FMU

If a Subsheet contains any Modelica model, perform these operations to replace the Modelica model with a cross-platform FMU:

For more details on compiling a Modelica model as a cross-platform FMU, see the documentation for Ansys Twin Deployer.

Limitations

Subcircuits that satisfy one or more of these conditions cannot be compiled into an FMU model:

Recompiling and Updating the Existing FMU component

In the Compile as Co-Simulation FMU dialog box, use the previously created co-simulation model name to update the existing FMU component.

Running a Simulation Using the FMU

The Twin Builder solver checks out a license during the co-simulation run. Set the following environment variable before launching the importing tool to specify the host name and the port number of the Ansys license server:

ANSYSLMD_LICENSE_FILE=<port>@<host>

Step-Size Under Co-Simulation Mode

Under the co-simulation mode for an applied communication step-size, hc, at the current communication time tci, Twin Builder may take multiple smaller step sizes to reach the next communication step, tci+1 (where tci+1 = tci + hc), based on the Hmin and Hmax values set at the export time. During the following scenarios, it may be necessary to take a step size, h, even below Hmin:

Note that it will never take a step-size larger than Hmax and it will never go beyond tci+1.

Simulation under the co-simulation mode will always be slower than the native simulation in the Twin Builder due to the communication overheads and input/output handling between the primary solver and the Twin Builder solver. The finer the communication step-size, the more delays will be incurred. Therefore, the communication step-size by the primary solver must be chosen appropriately to avoid those delays.

For the detailed mathematical background on FMI co-simulation, see section 4.1 of the FMI 2.0 Standard.