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

BoundsError access Bool #63

Closed
AnHeuermann opened this issue Jan 10, 2022 · 2 comments
Closed

BoundsError access Bool #63

AnHeuermann opened this issue Jan 10, 2022 · 2 comments

Comments

@AnHeuermann
Copy link

AnHeuermann commented Jan 10, 2022

Description

When I simulate a FMU generated from the Modelica Standard Library I get a bounds error.

How to reproduce

Consider the following minimal example with a CS-ME 2.0 FMU Modelica.Mechanics.Translational.Examples.Damper.fmu generatet from OpenModelica (OMCompiler v1.19.0-dev.505+ga499198eb3):

using FMI

myFMU = fmiLoad("Modelica.Mechanics.Translational.Examples.Damper.fmu")
fmiInstantiate!(myFMU)
success, simData = fmiSimulate(myFMU, 0.0, 1.0)

The error message:

julia> success, simData = fmiSimulate(myFMU, 0.0, 1.0)
ERROR: BoundsError: attempt to access Bool at index [2]
Stacktrace:
 [1] indexed_iterate(I::Bool, i::Int64, state::Nothing)
   @ Base ./tuple.jl:98
 [2] top-level scope
   @ REPL[4]:1

OMSimulator can simulate the FMU fine, so I guess it is not an issue with the FMU. But I didn't test a non-OpenModelica tool on it.

Additional files

Here is the FMU (remove the .zip file extension) with Linux binaries:
Modelica.Mechanics.Translational.Examples.Damper.fmu.zip


Version 'n stuff

OS: Ubuntu 20.04
Julia:

Julia Version 1.7.1
Commit ac5cc99908 (2021-12-22 19:35 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: Intel(R) Core(TM) i7-10700KF CPU @ 3.80GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-12.0.1 (ORCJIT, skylake)
(@v1.7) pkg> status FMI
      Status `~/.julia/environments/v1.7/Project.toml`
  [14a09403] FMI v0.3.6

OpenModelica: OMCompiler v1.18.1 and v1.19.0-dev.505+ga499198eb3

@AnHeuermann
Copy link
Author

Okay, I just called the simulate function wrong. From the README I got that I can call it like

success, simData = fmiSimulate(myFMU, 0.0, 10.0; recordValues=["mass.s"])

but when I remove recordValues from the call the return value will change and only return one bool success. And that is the reason for the error.

Is this a good idea to have the function interface change on a optional argument? I expected it to save all variables when I don't specifically tell fmiSimulate what I want to save, but instead it saved nothing.

@ThummeTo
Copy link
Owner

Believe it or not: We already had this discussion internally :-D

Should a function always return the same pattern? There are pros and cons, but we decided to don't return "dummy"-values if they are not needed/used. On the other hand many languages don't support this return feature, so for developers from these languages this behaviour is a bit unexpected. We decided to use the language features of Julia in this case. (you can call ?fmi2Simulate, the keyword arguments and return values are explained there)

But I am open for other opinions of course!

BTW: I will move this to discussions.

Repository owner locked and limited conversation to collaborators Jan 11, 2022
@ThummeTo ThummeTo converted this issue into discussion #65 Jan 11, 2022

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