Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register

Compile cosimulation FMU via OMPython API call

Compile cosimulation FMU via OMPython API call

Hi,

I am trying to compile a cosimulation FMU via omc by using the OMpython.

load_modelica = ModelicaSystem(test.mo, 'test', ['Modelica'],commandLineOptions="fmuType=cs")
ffmu = load_modelica.convertMo2Fmu()

I still get the default Model exchange FMU and not a cosimulation FMU. Have I set any flags wrong here?

Hope you can help me.

Best,

Edited by: ankiagg - Oct-27-20 21:06:35

Re: Compile cosimulation FMU via OMPython API call

Strangely it seems is not possible to send arguments to convertMo2Fmu. There is a bug report about it here:
https://trac.openmodelica.org/OpenModelica/ticket/6084
I guess that one is from you as well.

The "easy fix" until we properly fix it is to:
1. First make a copy of C:\Program Files\OpenModelica1.16.0-64bit\lib\omc\*.mo files someplace else.
2. Edit:
C:\Program Files\OpenModelica1.16.0-64bit\lib\omc\ModelicaBuiltin.mo
and
C:\Program Files\OpenModelica1.16.0-64bit\lib\omc\NFModelicaBuiltin.mo
locate translateModelFMU Modelica function in there and make the line:

Code:


input String fmuType = "me"

into:

Code:


input String fmuType = "cs" // or "cs_me"

Then when you call convertMo2Fmu with no arguments it will build you a "cs" or "cs_me" FMU.

Re: Compile cosimulation FMU via OMPython API call

This work around works. Thanks. Also, a similar work around is required while running it inside a linux docker container?

Also, is it possible to export cosimulation FMUS with Cvode as their solver via OMPython call? I saw that Cvode has been added in 1.16.0 release. Not sure, how to set

setCommandLineOptions("--fmiFlags=s:cvode").

Would this work (after I have set the default from me to cs, the way you suggested?

load_modelica = ModelicaSystem(test.mo, 'test', ['Modelica'],commandLineOptions="--fmiFlags=s:cvode")
ffmu = load_modelica.convertMo2Fmu()

Edited by: ankiagg - Oct-28-20 06:58:30

Re: Compile cosimulation FMU via OMPython API call

Can confirm that the way I tried works.

There are 0 guests and 0 other users also viewing this topic
You are here: