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
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