I think Nim could shine for simulations.

People use Simulink or OpenModelica with Modelica language. There are [many 
softwares](https://fmi-standard.org/tools/) that can export those physical 
models as FMU files which follow the FMI standard.

FMU are .zip files which contain libraries (.dll or .so) and some .xml 
description files. As far as I know, neither Python nor Julia can export those 
models easily to FMU files. Julia has the problem that the runtime is pretty 
big, so even when done manually, it [requires more than 
100Mb](https://sjc1.discourse-cdn.com/business5/uploads/julialang/original/2X/3/35f4480e1109c19add4c8e8ccb7ca657dba94f8f.png)
 files.

I am trying to do this in Nim. To achive it I would like to use: fmusdk 
<https://github.com/qtronic/fmusdk>. As an example, I would like to port the 
following example: 
[bouncingBall](https://github.com/qtronic/fmusdk/tree/master/fmu20/src/models/bouncingBall).
 But I am not sure about what should I do.

Looking at 
[bouncingBall.c](https://github.com/qtronic/fmusdk/blob/master/fmu20/src/models/bouncingBall/bouncingBall.c),
 it follows the following structure::
    
    
    #include "fmuTemplate.h"
    /*
     ...
    define a few C functions which represent the model
    ...
    */
    #include "fmuTemplate.c"
    
    Run

Which one of the following approaches would be better?

  1. Implementing the model in Nim, export it into C moking above structure. Is 
this feasible?
  2. Creating bindings for fmuTemplate.h and calling it from a 
bouncingBall.nim? This is what I would do, but I don't what to do with that 
#include "fmuTemplate.c" at the end of the file. I don't feel confortable with 
C language.



Regards

Reply via email to