Skip to content

generosolombardi-av/fmi4j-multiplatform-runtime

Repository files navigation

FMI4j Multiplatform Runtime

This repository is a community continuation of NTNU-IHB/FMI4j, with a practical focus on keeping the FMI4j import runtime usable in modern JVM applications across multiple native platforms.

The original FMI4j project has been archived by its author. This fork keeps the original codebase and license intact, while adding reproducible native runtime builds, packaging notes, and examples for current Java/Spring Boot digital twin projects.

Fork maintainer:

  • Generoso Lombardi - creator and technical director of the SinergIA project

Initial maintenance focus:

  • macOS ARM64
  • macOS x86_64
  • macOS universal darwin64 runtime
  • Windows x86_64
  • Windows ARM64
  • Linux x86_64
  • Linux ARM64

The first concrete goal is to make the fmi-import native JNI library available for the architectures above without requiring each user to patch the runtime JAR manually.

Current Status

Area Status
Original FMI4j import API Preserved
Original FMI4j model description API Preserved
macOS ARM64 native runtime Documented, script foundation added
macOS x86_64 native runtime Documented, script foundation added
macOS universal runtime Documented, script foundation added
Windows x86_64 runtime Existing upstream support, to be repackaged
Windows ARM64 runtime Verified native runtime included
Linux x86_64 runtime Existing upstream support, to be repackaged
Linux ARM64 runtime Verified native runtime included
Maven Central publication Planned
Example JVM/Spring Boot FMU loader Added

Documentation Added By This Fork

Scripts Added By This Fork

  • scripts/build-macos-universal.sh
  • scripts/package-runtime-jar.sh
  • scripts/build-linux-aarch64.sh
  • scripts/build-windows-arm64.bat

The scripts are intentionally small and explicit. They are meant to make the native runtime packaging process inspectable before it is automated further with CI.

Recommended GitHub Topics

fmi
fmu
fmi4j
fmi-standard
fmi2
co-simulation
java
kotlin
jni
digital-twin
openmodelica
macos-arm64
apple-silicon
multiplatform
linux-arm64
linux-aarch64
windows-arm64
windows-aarch64

Original FMI4j README

The original project description follows.

License: MIT contributions welcome

CI Gitter

FMI4j is a software package for dealing with Functional Mock-up Units (FMUs) on the Java Virtual Machine (JVM), written in Kotlin.

FMI4j supports import of both FMI 1.0 and 2.0 for Co-simulation. For Model Exchange version 2.0 is supported.

Compared to other FMI libraries targeting the JVM, FMI4j is considerably faster due to the fact that we use JNI instead of JNA. Considering FMI-import, a significant speedup (2-5x) compared to other open-source FMI implementations for the JVM should be expected.

Maven artifacts are available through Central


FMI import

class Demo {
    
    void main(String[] args) {
        
        Fmu fmu = Fmu.from(new File("path/to/fmu.fmu")); //URLs are also supported
        FmuSlave slave = fmu.asCoSimulationFmu().newInstance();

        slave.simpleSetup();
        
        double t = 0;
        double stop = 10;
        double stepSize = 1.0/100;
        while(t <= stop) {
            if (!slave.doStep(t, stepSize)) {
                break;
            }
            t += stepSize;
        }
        slave.terminate(); //or close, try with resources is also supported
        fmu.close();
        
    }
    
}

Would you rather build FMUs using a JVM language? Check out FMU4j!
Or maybe build FMUs using Python? Check out PythonFMU!
Or would you rather simulate FMUs using C++? Check out FMI4cpp!
Need to distribute your FMUs? FMU-proxy to the rescue!
Need a complete co-simulation framework with SSP support? Check out Vico