Skip to content

Test FMI 3.0 Co-Simulation with FMPy and CVODE - #400

Merged
sjoelund merged 1 commit into
masterfrom
fmi3-via-fmpy
Nov 7, 2026
Merged

sjoelund merged 1 commit into
masterfrom
fmi3-via-fmpy

Conversation

@sjoelund

@sjoelund sjoelund commented Nov 6, 2026

Copy link
Copy Markdown
Member

The FMI jobs test FMI 2.0 only. To test FMI 3.0 without a second build of each FMU, an OpenModelica change (not yet merged; merge it first) lets omc build one FMU that serves both versions: buildModelFMU(version="2.0+3.0"). Its binary has the fmi2* and the fmi3* functions. The FMU has the FMI 2.0 layout, and modelDescription.fmi3.xml holds the FMI 3.0 description.

Add the entry field fmiVersion to configs/fmi-simulators.json. If a simulator of the job has fmiVersion 3.0, build the FMU with version="2.0+3.0". That simulator runs a copy of the FMU with modelDescription.fmi3.xml as modelDescription.xml and the binaries in the FMI 3.0 platform directory (x86_64-linux, not linux64).

Add one such simulator, fmpy-fmi3-cs-cvode: Co-Simulation with CVODE, run by FMPy. It fills master-fmi3-cs-cvode, and only fmi_master runs it, because the omc of the maintenance branches does not know version="2.0+3.0". OMSimulator cannot run these FMUs as FMI 3.0 yet (OpenModelica/OMSimulator#1694).

Assisted-by: Claude Opus 5.5

The FMI jobs test FMI 2.0 only. To test FMI 3.0 without a second
build of each FMU, an OpenModelica change (not yet merged; merge it
first) lets omc build one FMU that serves both versions:
buildModelFMU(version="2.0+3.0"). Its binary has the fmi2* and the
fmi3* functions. The FMU has the FMI 2.0 layout, and
modelDescription.fmi3.xml holds the FMI 3.0 description.

Add the entry field fmiVersion to configs/fmi-simulators.json. If a
simulator of the job has fmiVersion 3.0, build the FMU with
version="2.0+3.0". That simulator runs a copy of the FMU with
modelDescription.fmi3.xml as modelDescription.xml and the binaries
in the FMI 3.0 platform directory (x86_64-linux, not linux64).

Add one such simulator, fmpy-fmi3-cs-cvode: Co-Simulation with
CVODE, run by FMPy. It fills master-fmi3-cs-cvode, and only fmi_master
runs it, because the omc of the maintenance branches does not know
version="2.0+3.0". OMSimulator cannot run these FMUs as FMI 3.0 yet
(OpenModelica/OMSimulator#1694).

Assisted-by: Claude Opus 5.5
@sjoelund

sjoelund commented Nov 6, 2026

Copy link
Copy Markdown
Member Author

This PR needs OpenModelica/OpenModelica#17887, which adds buildModelFMU(version="2.0+3.0"). Merge #17887 first. Without it, every model of the fmi_master job fails to build, because omc master does not know version="2.0+3.0" yet.

sjoelund added a commit to sjoelund/OpenModelica that referenced this pull request Nov 6, 2026
This is for OpenModelicaLibraryTesting only, not for users.
OpenModelica/OpenModelicaLibraryTesting#400 tests FMI 3.0 Co-Simulation
without a second build of each FMU.

buildModelFMU(version="2.0+3.0") translates the model once and builds
one shared library with the fmi2* and the fmi3* functions. The FMI 3.0
causalization of unconnected acausal connectors is skipped, so the FMI
2.0 side is the same as a plain FMI 2.0 export.

The FMU has the FMI 2.0 layout: modelDescription.xml is the FMI 2.0
description and the binary is in binaries/linux64.
modelDescription.fmi3.xml is the FMI 3.0 description. To run the FMU
as FMI 3.0, replace modelDescription.xml with it and rename
binaries/linux64 to binaries/x86_64-linux.

The FMI 2.0 and the FMI 3.0 interface both compile
fmu_model_interface.c.inc, so they define the same symbols, and their
ModelInstance structs are different. So CodegenFMU also writes
<model>_FMU2.h and <model>_FMU2.c, and the FMU build compiles them with
fmu2_model_interface.c into one object whose hidden symbols objcopy
makes local. This works only for --simCodeTarget=C and a shared library
on Linux.

Fixes OpenModelica#17886

Assisted-by: Claude Opus 5.5
sjoelund added a commit to sjoelund/OpenModelica that referenced this pull request Nov 6, 2026
This is for OpenModelicaLibraryTesting only, not for users.
OpenModelica/OpenModelicaLibraryTesting#400 tests FMI 3.0 Co-Simulation
without a second build of each FMU.

buildModelFMU(version="2.0+3.0") translates the model once and builds
one shared library with the fmi2* and the fmi3* functions. The FMI 3.0
causalization of unconnected acausal connectors is skipped, so the FMI
2.0 side is the same as a plain FMI 2.0 export.

The FMU has the FMI 2.0 layout: modelDescription.xml is the FMI 2.0
description and the binary is in binaries/linux64.
modelDescription.fmi3.xml is the FMI 3.0 description. To run the FMU
as FMI 3.0, replace modelDescription.xml with it and rename
binaries/linux64 to binaries/x86_64-linux.

With the C simulation runtime, the FMI 2.0 and the FMI 3.0 interface
both compile fmu_model_interface.c.inc, so they define the same symbols,
and their ModelInstance structs are different. So CodegenFMU also writes
<model>_FMU2.h and <model>_FMU2.c, and the FMU build compiles them with
fmu2_model_interface.c into one object whose hidden symbols objcopy
makes local. This works only for a shared library on Linux.

With --simCodeTarget=C+Rust, libSimulationRuntimeRust serves both
interfaces. <model>_FMU.c includes the FMI 2.0 wrappers next to the FMI
3.0 ones, and no second object is necessary.

A wasm simCodeTarget gets the C export, as FMI 1.0 does. So the test
runs in all three testsuite lanes.

Fixes OpenModelica#17886

Assisted-by: Claude Opus 5.5
sjoelund added a commit to OpenModelica/OpenModelica that referenced this pull request Nov 6, 2026
This is for OpenModelicaLibraryTesting only, not for users.
OpenModelica/OpenModelicaLibraryTesting#400 tests FMI 3.0 Co-Simulation
without a second build of each FMU.

buildModelFMU(version="2.0+3.0") translates the model once and builds
one shared library with the fmi2* and the fmi3* functions. The FMI 3.0
causalization of unconnected acausal connectors is skipped, so the FMI
2.0 side is the same as a plain FMI 2.0 export.

The FMU has the FMI 2.0 layout: modelDescription.xml is the FMI 2.0
description and the binary is in binaries/linux64.
modelDescription.fmi3.xml is the FMI 3.0 description. To run the FMU
as FMI 3.0, replace modelDescription.xml with it and rename
binaries/linux64 to binaries/x86_64-linux.

The FMI 2.0 and the FMI 3.0 interface both compile
fmu_model_interface.c.inc, so they define the same symbols, and their
ModelInstance structs are different. So CodegenFMU also writes
<model>_FMU2.h and <model>_FMU2.c, and the FMU build compiles them with
fmu2_model_interface.c into one object whose hidden symbols objcopy
makes local. This works only for --simCodeTarget=C and a shared library
on Linux.

Fixes #17886

Assisted-by: Claude Opus 5.5
@sjoelund
sjoelund merged commit cc38413 into master Nov 7, 2026
7 checks passed
@sjoelund
sjoelund deleted the fmi3-via-fmpy branch November 7, 2026 06:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant