Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get started with Functional Mock-up Interface? #130

Open
gaelforget opened this issue Jan 7, 2025 · 3 comments
Open

How to get started with Functional Mock-up Interface? #130

gaelforget opened this issue Jan 7, 2025 · 3 comments

Comments

@gaelforget
Copy link
Owner

If I wanted to define FMUs for this package, how should I get started?

We talked about this yesterday at JuliaEO25 with @ChrisRackauckas, and @evetion also in relation to https://github.com/Deltares/BasicModelInterface.jl and https://thummeto.github.io/FMI.jl/dev/

@ChrisRackauckas
Copy link

@AayushSabharwal do we have some kind of simple doc of how one can make any code something that can compile to the FMI interface? That might be a nice thing to generally setup CC @ThummeTo

@AayushSabharwal
Copy link

Given an ODE model, coercing it into functions that mimic the FMI spec isn’t a huge deal (for the most part) since I assume we basically have an RHS function and some events. The rest is just bookkeeping global state. Building the FMU on the other hand is annoying because we need to expose it through C and there’s a lot of funny things to do with running julia through C, bundling it, etc. By and large the global state is the annoying bit in my opinion, second only to static compilation/C bindings.

In terms of documentation, I feel like the best we can do here is translate MTK/SciML terminology to FMI terminology and generally point people to the right parts of the spec. If there are better ideas, I'm open to them.

@ThummeTo
Copy link

ThummeTo commented Jan 23, 2025

@AayushSabharwal do we have some kind of simple doc of how one can make any code something that can compile to the FMI interface? That might be a nice thing to generally setup CC @ThummeTo

This is on the todo for a while now :-)
Didn't touch the package for a while, but I will do a notebook or similar, this won't take too long.

From the technical perspective @AayushSabharwal you are correct, it's not complicated but you need to know the entire FMI-spec to compile a running FMU. The "annoying" part is already part of the FMIExport.jl. All you have to define is (as you correctly said) the right-hand side of your ODE and some callbacks (like event handling in DiffEqCallbacks) but with a FMI-specific interface (state- and time-events) - so we reduced the interface to a total of five functions that need to be defined (instead of like 50 as in the FMI spec). You can check the definitions within this file, that is compiled to an FMU (the well known mixed continuous-discrete bouncing ball). However I just noticed that event handling is not working (caused by FMIExport) as it should. I will fix that very soon.

For now only ME is implemented. CS should be easy (CS is like ME with extra steps) - if this is needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants