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

'setFloat64' not working when setting the initial value of states with FMU3.0? #736

Open
Rick-Wang0516 opened this issue Jan 25, 2025 · 0 comments

Comments

@Rick-Wang0516
Copy link

I am trying to upgrade from using FMI2.0 to FMI3.0 since the adjointDerivative could be very helpful in this application, in which it is needed to set the initial values of both states and inputs.

With FMU2.0, the setReal and getReal work successfully for both states and inputs

fmu = fmpy.fmi2.FMU2Model(guid=fmu_md.guid, unzipDirectory=unzipdir, modelIdentifier=fmu_md.modelExchange.modelIdentifier)
fmu.instantiate()

fmu.setupExperiment()
fmu.enterInitializationMode()
fmu.exitInitializationMode()

fmu.setReal([valueReference], [init_value])
fmu.getReal([valueReference])[0]

But in with FMU3.0:

fmu = fmpy.fmi3.FMU3Model(guid=fmu_md.guid, unzipDirectory=unzipdir, modelIdentifier=fmu_md.modelExchange.modelIdentifier)
fmu.instantiate()

fmu.enterInitializationMode()
fmu.exitInitializationMode()

fmu.setFloat64([valueReference], [init_value])
fmu.getFloat64([valueReference])[0]

setFloat64 can only set the value of input, while getFloat64 can get the value of all.

I checked an example and explanation, but I suppose it is related only to the input. I would like to ask, with FMI3.0, what is the correct manner to set the initial value of the states? An example would be very appreciated.

Thanks a lot!

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

1 participant