After a very long time, I manage to create and FMU that actually works with 
OpenModelica with [fmu.nim](https://github.com/mantielero/fmu.nim).

[FMU - 
Functional_Mock-up_Interface)](https://en.wikipedia.org/wiki/Functional_Mock-up_Interface)
 is a kind of file that it is used for simulation. Basically is a zip file that 
contains libraries (.so / .dll), .xml, . html, source code, ... and it is used 
to exchange simulation models accross different applications. For example, you 
can create a thermodynamic model in Proosis and export it to an FMU. Then you 
can create a control model in Matlab and integrate both models in Dymola.

I created a model that simple increase a counter in 1 every second. The model 
is 
[inc.nim](https://github.com/mantielero/fmu.nim/blob/main/examples/inc/inc.nim).
 When you compile this with:
    
    
    nim c -r -d:fmu inc
    
    
    Run

you get `inc.fmu`.

Later you can [import this model in 
OpenModelica](https://github.com/mantielero/fmu.nim#importing-an-fmu-in-openmodelica),
 create a model using it and perform a simulation:

It took me years (starting and stopping the project). For a pro-dev this is 
probably easy. But this says a lot about how good Nim is. Enabling a non-pro 
dev being able of doing something like this.

Next step will be easy (I think). By compiling the model with `zig`, I think I 
will be able to create FMU's that work in Windows and Linux at the same time.

Reply via email to