Using string parameters in FMU models

This blog post looks at exporting models as FMUs containing string parameters and modifying those string parameters in the FMU before simulating.

Process for creating FMUs with string parameters and modifying these strings

The basic instructions for creating an FMU containing modifiable string parameters are below:

  1. Make sure the string parameters to be modified are not evaluated, that is having
  2. When exporting to FMU, by pressing  Ctrl+F9, select Export with string parameters as in the image belowselect Export with string parameters
  3. Import the FMU into Dymola
  4. The string parameters can be edited by right clicking on the model in the Component Browser and selecting Parameters or by editing the string parameter in the FMU model.
    in the Component Browser select Parameters

Note: if the size of an array is dependent on the string parameter then Dymola will generate an error during translation.
A workaround for this issue is to set the array size in the model manually, but this generally will only work when the array size does not change.

In Dymola versions before Dymola 2019 FD01 setting the string parameter using the Component browser to ModelicaServices.ExternalReferences.loadResource(…) causes Dymola to crash. This issue should now be fixed in Dymola 2019 FD01.

Vehicle on track example

The VeSyMA TerrainServer library makes it possible to obtain data from high fidelity sampled tracks by interfacing with the rFpro TerrainServer. In the closed loop driver example (TerrainServer.Experiments.Examples.ClosedLoopExample), a vehicle is driven in closed loop around a track. In the following case the ClosedLoopExample is exported to an FMU in such a way that the vehicle could be driven around any specified track following any specified path.

To do this the TerrainServer.Experiments.Examples.ClosedLoopExample model is extended and modified as shown below:

TerrainServer.Experiments.Examples.ClosedLoopExample model extended and modified

In the code above the fileName and trackName parameters are propagated to the top level and the annotation Evaluate=false is used. Also road.animation is set to false as this road animation generates an array with a size that is dependent on fileName.

The Real-time settings were used by calling the following function in the Dymola command line:, setFlagsOnly=true);

Then the ClosedLoopExampleForExport model was translated into a FMU, with Export with string parameter selected. Then the ClosedLoopExample FMU was imported into Dymola.

The model was then simulated on the SteeringPad with a double lane change path:

fileName and track string parameters were modified so that the FMU ran the vehicle on OrchardLake with a path going around Orchard Lake:


Written by: Garron Fish – Chief Engineer 

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


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


© Copyright 2010-2018 Claytex Services Ltd All Rights Reserved. | Designed by CMA Marketing

Log in with your credentials

Forgot your details?