Skip to content

BoundsError access Bool #63

Closed
Closed

Description

@AnHeuermann

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

Activity

  1. AnHeuermann commented on Jan 11, 2022

    @AnHeuermann
    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.

  2. ThummeTo commented on Jan 11, 2022

    @ThummeTo
    Collaborator

    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.

  3. locked and limited conversation to collaborators on Jan 11, 2022
  4. converted this issue into a discussion #65 on Jan 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions