Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Question: Setting FMU inputs in fmi2EvaluateME() #89

Closed
hejersbo opened this issue May 17, 2023 · 2 comments
Closed

Question: Setting FMU inputs in fmi2EvaluateME() #89

hejersbo opened this issue May 17, 2023 · 2 comments

Comments

@hejersbo
Copy link

hejersbo commented May 17, 2023

Hi,

This is not a bug report. Merely a question (and perhaps clarification of a my misunderstanding :-))

I would like to specify the FMU inputs when calling fmiEvaluteME() and I can see that the fmiEvaluate() has arguments setValueReferences and setValues. But is it possible to set an input function (like for fmiSimulateME) that is evaluated with the input time of the ODE solver. So e.g. one could have something like sin(t) being the input function for the FMU.

@hejersbo
Copy link
Author

The reason for this is that I try to make a simple example - more or less replicating the simple_hybrid_ME example of the repo but with a different ME FMU. But I setup the neural FMU just like the example (using fmiEvaluateME()).

# NeuralFMU setup
numStates = fmiGetNumberOfStates(referenceFMU)

net = Chain(inputs -> fmiEvaluateME(referenceFMU, inputs),
            Dense(numStates, 16, tanh),
            Dense(16, 16, tanh),
            Dense(16, numStates))

neuralFMU = ME_NeuralFMU(referenceFMU, net, (tStart, tStop), Tsit5(); saveat=tSave);

@ThummeTo
Copy link
Owner

Sorry for the late reply, somehow I skipped that notification...

Year, you can totally do that, see this test here:
https://github.com/ThummeTo/FMIFlux.jl/blob/568e585d607abe25e51b20a5c7fadb7be38807fa/test/hybrid_ME.jl#LL134C6-L134C6

Basically your chain would look like this:

function myInputFunction(t)
   return [sind(t)]
end

net = Chain(x-> referenceFMU(;x=x, u_refs=setVRs, u=myInputFunction(  getCurrentComponent(referenceFMU).t  )),
            Dense(numStates, 16, tanh),
            Dense(16, 16, tanh),
            Dense(16, numStates))

Repository owner locked and limited conversation to collaborators Jun 19, 2023
@ThummeTo ThummeTo converted this issue into discussion #90 Jun 19, 2023

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants