ThummeTo / FMIExport.jl

FMIExport.jl is a free-to-use software library for the Julia programming language which allows for the export of FMUs (fmi-standard.org) from any Julia-Code. FMIExport.jl is completely integrated into FMI.jl.
MIT License
22 stars 3 forks source link

Provide simple example #36

Closed weberscode closed 1 month ago

weberscode commented 1 year ago

Hi all,

is it possible to provide a simple example of a julia generated model exchange fmu that i could include to my Modelica model.

The input should be u and the output y = asin(bu). The values a and b are constant parameters.

kind regards Simon

ThummeTo commented 1 year ago

Hey @weberscode; did you check out e.g. the BouncingBall Example here? It's not as easy as the system that you provided, but still really really easy.

You basically can remove all continuous and discrete states. To be honest, I never tested a non-dynamic simulation model with pure I/O-behavior, but this should work, too. Otherwise feel free to report.

Other tutorial are WIP BTW. Best regards!

larschrj commented 10 months ago

I might add that the bouncing ball example code in the docs seems to be broken at the moment. Seems to be a case of updating the docs.

FMU_FCT_INIT only returns a tuple with 5 values rather than 6 which is what fmi2CreateSimple seems to expect.

Seems to be xd that is missing in the return (no of discrete events as far as I can discern from the source). By extension, FMU_FCT_OUTPUT and FMU_FCT_EVENT need to accept xd as an argument (FMU_FCT_OUTPUT = function(t, x, ẋ, xd, u, p)...)

The jl file in the example folder has corrected this. It seems to be broken in some other way at least when I (perhaps incorrectly) do an include on it to try and run it on an Apple M1 (which I know is not officially supported) or WSL Ubuntu.

ThummeTo commented 10 months ago

Ok, we check this. There will be a little patch (v0.3.2) anyway within the next two weeks. I also triggered a test run on the server (which is Windows only): Test run

larschrj commented 10 months ago

Got the example working in v1.10 on Windows 11.