ghorwin / FMICodeGenerator

A Code Generator that creates native C/C++ code to build Functional Mock-Up Units (FMU) with support for FMI version 2.0 (rollback)
BSD 3-Clause "New" or "Revised" License
51 stars 25 forks source link

Real value inputs and the compliance checker #32

Closed daviddecobee closed 4 years ago

daviddecobee commented 4 years ago

Thanks for contributing this tool, it's really made my entry into the world of building an FMU straight forward.

I've run across a problem using Real's as input into my FMU and I'm not sure where the issue lies. I'm using the compliance checker 2.0.4 and when I turn on the -f flag I see that my first Real input on a given line of the input file is copied to all real variables. If I convert the model to use integers for the same field I don't see the problem. It's easy to suspect the problem lies with the compliance checker but I thought I'd ask here before posting there.

To be clear, here is what I see. Take a model with inputs A, B, C all reals and using the compliance checker with an input similar to:

"time","A","B","C"
0,1.0,2.0,3.0

The output file will show:

"time","A","B","C"
0,1.0,1.0,1.0

Print statements in my FMU confirm what I see in the output file. Again, if I use integers no issue, it really feels like a problem with the compliance checker but any insight you can provide is much appreciated.

ghorwin commented 4 years ago

Hi, looks like this could be a bug. I'll check the generated code to make sure (though this will take a few days). Thanks for pointing this out.

ghorwin commented 4 years ago

Tested it with:

Now I suspect an error in the compliance checker.. I'll try with the newest version.

ghorwin commented 4 years ago

Strange, in my test, everything checks out ok. Here's my input again:

test.zip

Command line for testing:

./fmuCheck.linux64 -f -i input.tsv -o output.tsv ../RealInputTest/build/RealInputTest.fmu

Seems to work.

daviddecobee commented 4 years ago

Your example was just what I needed to find the key issue. If I change the real inputs to variability "discrete" instead of continuous I am able to "break" the example you've provided.

I'm not sure I understand the difference between the "discrete" and "continuous" variability. It's quite possible I should not be using "discrete".

daviddecobee commented 4 years ago

@ghorwin , I'm realizing now that I definitely do not want continuous for my model, when I run it through the checker it does a linear interpolation. I definitely want the step inputs provided by the "discrete" variability.

Also I should state that I'm using co-simulation not model exchange.

ghorwin commented 4 years ago

If I understand correctly, the problem arises when an FMU generated with the code generator is processed by the compliance checker. The information whether values change continuously or discretely should not have any effect on the FMU behavior - only on how a master handles the variables. Thus, I feel there is nothing that can be improved in the code generator, right?

Please close the ticket if this is resolved (and possible post a bug ticket for the compliance checker).

daviddecobee commented 4 years ago

Agreed I've raised the issue there.