CATIA-Systems / FMPy

Simulate Functional Mockup Units (FMUs) in Python
Other
429 stars 118 forks source link

Best way to interact with a FMU #656

Closed rpatureau closed 6 months ago

rpatureau commented 6 months ago

It is more a question than an issue

I wanted to be able to interact with an FMU to update the inputs either in co-simulation or with Model exchange. From https://github.com/claxerity/FMPy/blob/master/fmpy/examples/custom_input.py, I knew it was possible to do so with doStep for co-simulation, and I found you could also do that for ModelExchange (#84) via step_finished

Now my question is: is there a difference between those two methods? Going with step_finished seems more generic as it works both with Model Exchange and co-simulation. What would be the advantage(s) of using doStep rather than step_finished?

Thanks in advance.

t-sommer commented 6 months ago

If you write your own simulation loop you can set the inputs directly (e.g. before calling doStep() in Co-Simulation). If you want to use FMPy's simulation loop you have to use the step_finished callback.