Repository navigation
Test FMI 3.0 Co-Simulation with FMPy and CVODE - #400
Merged
Merged
Conversation
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
This was referenced Nov 6, 2026
Member
Author
|
This PR needs OpenModelica/OpenModelica#17887, which adds |
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
added a commit
that referenced
this pull request
Nov 10, 2026
* Let FMPy record the variables of FMI 3.0 FMUs #399 gave FMPy the variables of the reference for FMI 2.0, but not the fmpy-fmi3-cs-cvode simulator of #400. That FMPy wrote only the outputs of the model. When the verifying omc started to fail on a variable that is not in the result (OpenModelica #17888), master-fmi3-cs-cvode lost 7241 verified models in one night. Give fmpy-fmi3-cs-cvode the same --output-variables. An FMI 3.0 FMU of OpenModelica can have an array as one variable with dimensions, x for x[1] to x[3], and FMPy writes all of its elements into one CSV cell, separated by spaces. So also give FMPy the names of the arrays, and after the simulation, give each element of an array its own column, named from the dimensions in modelDescription.xml. * Do not compare the Dymola-only variables of a reference Reference results that Dymola wrote have variables that are not in the model: CPUtime, EventCounter, Time, _dummy and _derdummy (the state of a model without states), NonlinearSystems.* (statistics of the solvers) and _GlobalScope.* (constants of packages). OpenModelica never writes them. Since the verifying omc fails on a variable that is not in the result (OpenModelica #17888), these variables made models of ClaRa and ThermofluidStream fail in all lanes: 280 to 950 models per lane in the runs of 2026-11-09. Remove them from the variables of the reference, and ignore them in the variables that diffSimulationResults reports. * Use OpenModelica names from comparisonSignals.txt readSimulationResultVars(openmodelicaStyle=true) gives the names of a reference in OpenModelica style: no spaces, and der(a.b) for a.der(b). The names of comparisonSignals.txt were used as written. The MSL references write stack.cell[1, 1].y, so the variableFilter did not match stack.cell[1,1].y and the simulation did not write it, and FMPy did not find it in the FMU. Give the names of comparisonSignals.txt the same style. * Rewrite reference files with referenceFilePreprocessor The CSV references of Buildings write the header without quotes, as time,booRep.y[1,1]. A CSV reader splits booRep.y[1,1] into booRep.y[1 and 1], so these variables were never compared: in the runs of 2026-11-09, 25 to 30 models of Buildings per lane failed this way. Add the configuration field referenceFilePreprocessor. It names a function that writes a copy of each reference file, and the models are compared against the copy. quoteCsvHeader joins the header fields that a comma inside [] or () split apart and puts each name in quotes. Use it for the CSV references of Buildings. Assisted-by: Claude Opus 5.5
dreivmeister
pushed a commit
to dreivmeister/OpenModelica
that referenced
this pull request
Nov 10, 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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