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

Call arguments instantiate, reset, terminate, freeInstance, setup are ignored in "simulate"-call #260

Closed
juguma opened this issue Dec 2, 2024 · 1 comment · Fixed by #261

Comments

@juguma
Copy link
Contributor

juguma commented Dec 2, 2024

When you want to simulate an fmu instance, you can specify what shall happen to the fmu instance in terms of setup, reset, instantiate, freeInstance, terminate, e.g. whether a new instance shall be created or an existing instance or the one you called the simulate-function with shall be used. However, these settings don't have an effect, instead the settings of fmu.executionConfig are taken.

Specifically, when prepareSolveFMU is called, these values are not included (not explicitly, not as kwargs), this calls function prepareSolveFMU in L210, and this calls prepareSolveFMU in L26 where instantiate and co. get their default values from the executionConfig.

My proposal is to simply add the named five keyword arguments in the prepareSolveFMU-call in fmi.jl. An alternative may be to remove them toplevel (for simulate) and handle it via executionConfig (which is a possible current workaround).

MWE:

using FMI, DifferentialEquations
using FMIZoo

fmu =  loadFMU("BouncingBall1D", "Dymola", "2023x"; type = :ME)

tspan = (getDefaultStartTime(fmu), getDefaultStopTime(fmu))
saveat = collect(tspan[1]:0.01:tspan[2])

inst = fmi2Instantiate!(fmu)
fmi2SetupExperiment(inst)
fmi2EnterInitializationMode(inst)
fmi2ExitInitializationMode(inst)
using FMI.FMIBase: handleEvents
handleEvents(inst)
fmu.instances
length(fmu.instances) == 1

sol = simulateME(inst, tspan; saveat=saveat, setup = false,  reset = false, instantiate = false, terminate = false, freeInstance = false)
   
length(fmu.instances) == 1 #<should be equal, but is not
#<-there is presumably more to test (like status etc) to check that the other commands took their effect. 
@juguma
Copy link
Contributor Author

juguma commented Dec 2, 2024

I realized, this only affects ME, for CS the arguments are already there.

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

Successfully merging a pull request may close this issue.

1 participant