Skip to content
forked from NTNU-IHB/FMI4j

FMI4j is a software package for dealing with Functional Mockup Units (FMUs) on the JVM platform

License

Notifications You must be signed in to change notification settings

fmi-tools/FMI4j

 
 

Repository files navigation

FMI4j

License: MIT contributions welcome

Gitter

CircleCI Build Status

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

FMI4j supports both FMI 1.0 and 2.0 for Co-simulation. For Model Exchange version 2.0 is supported.
For Model Exchange, solvers from Apache Commons Math can be used.

Compared to other FMI libraries targeting the JVM, FMI4j is considerably faster due to the fact that we use JNI with manually optimized C++-code instead of JNA or SWIG generated bindings. A significant speedup (2-5x) compared to other FMI implementations for the JVM, such as JFMI and JavaFMI, should be expected.

Software API

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();
        
        // Model Exchange is also supported:
        //
        // Solver solver = ApacheSolvers.euler(1E-3);
        // FmuSlave slave = fmu.asModelExchangeFmu(solver).newInstance(); 
        
        slave.simpleSetup();
        
        double stop = 10;
        double stepSize = 1.0/100;
        while(slave.getSimulationTime() <= stop) {
            if (!slave.doStep(stepSize)) {
                break;
            }
        }
        slave.terminate(); //or close, try with resources is also supported
        fmu.close(); // <- also done automatically by the library if you forget to do it yourself
        
    }
    
}

Due to how cumbersome it is to publish artifacts to Maven Central, new releases can only be obtained using jitpack.

repositories {
    /*...*/
    maven { url 'https://jitpack.io' }
}

dependencies {
    def fmi4j_version = "..."
    implementation "com.github.NTNU-IHB.FMI4j:fmi-import:${fmi4j_version}"
}

To get started head over to the Wiki!

About

FMI4j is a software package for dealing with Functional Mockup Units (FMUs) on the JVM platform

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 45.9%
  • Kotlin 41.3%
  • C++ 9.2%
  • C 3.6%