How to export CoSim FMUs with Inline Integration – Part 2 – Source code edition

In my previous entry on the Claytex blog post, I explained how to export FMUs for Co-Simulation with inline integration settings. For most users, this would suffice, however for users wishing to export source code CoSim FMUs with Inline Integration, the methodology required is slightly different. At first glance, it appears to not be possible, but it is.

It is important to cover source code FMUs, as some users require re-compilation of the FMUs post-export to conform to their system architecture and / or deployed applications. 

Procedure

STEP 1: Select inline solver settings

While in the Simulation tab, select the base solver type of Euler. Then, set the desired inline integration option to be used via the Realtime tab in the Simulation Setup menu. Be sure to select the inline integration order if required by the selected inline integration method. Note that this can also be done via text in the commands window with advanced flag settings as well as within a function or script used to more consistently create your FMU.

Figure 1: There are various types of Inline Integration methods to choose from, each with their own characteristics
Figure 1: There are various types of Inline Integration methods to choose from, each with their own characteristics

STEP 2: FMU type selection.

To apply inline integration including source code, only 3 options are available (due to selecting source code export); Model Exchange, Co-simulation using Cvode, and Model exchange and Co-simulation using Cvode. The fourth option on the list, Co-simulation with Dymola solvers, is incompatible with source code export.

Figure 2: Using the GUI is the simplest way to take an overview of all the FMI export options available in Dymola
Figure 2: Using the GUI is the simplest way to take an overview of all the FMI export options available in Dymola

If you are noticing that some of the co-simulation options listed in step 2 specify Cvode, and the others are only Model exchange… then you may give up and think you may not be able to export a model with Inline Integration.

But don’t!

The difference between the “Co-Simulation with Cvode” and “Co-Simulation with Dymola Solvers” options is that the latter can include proprietary Dymola solvers in the exported FMU. For this reason, the option of exporting as a source code FMU is prohibited.

The former option of “Co-Simulation with Cvode”, actually (and counter intuitively) enables export with inline integration.

STEP 3: Verifying exported model

We can verify that our FMU has exported with a fixed step solver including inline integration easily, by either checking the model description .xml file of the FMU or by loading the FMU and reading the documentation.

Figure 3: The model description .xml file can be located in the FMU output folder, automatically generated in the Dymola working directory
Figure 3: The model description .xml file can be located in the FMU output folder, automatically generated in the Dymola working directory

Closing remarks

Although it seems not to be possible at first glance, exporting a source code CoSim FMUs with Inline Integration is in fact a task which is supported in Dymola. If you ever have a need for generating a source code FMU with inline integration, hopefully this blog post will help you achieve the task!

Nate Horn – Vice President

Please get in touch if you have any questions or have got a topic in mind that you would like us to write about. You can submit your questions / topics via: Tech Blog Questions / Topic Suggestion.

CONTACT US

Got a question? Just fill in this form and send it to us and we'll get back to you shortly.

Sending

© Copyright 2010-2020 Claytex Services Ltd All Rights Reserved

Log in with your credentials

Forgot your details?