Message Boards Message Boards

0
|
5426 Views
|
3 Replies
|
6 Total Likes
View groups...
Share
Share this post:

FMU export fails for a block with algorithm section and discrete variables

Posted 3 years ago

I'm trying to export a Co-simulation FMU (2.0) of a model with a block class with discrete variables and an algorithm section but it gives errors when compiling. I can't post the whole code of the block here because I'm not authorized by the company. But the block code is something like:

block model_name
    Real real_var1;
    Modelica.Blocks.Interfaces.RealInput array_input_var1[10];
    Modelica.Blocks.Interfaces.RealOutput output_var1;

    parameter Integer int_limit;
    Boolean bool_var1;
    Integer int_var1;
equation
    real_var1 = array_input_var1[0];
algorithm
    if array_input_var1[0] > 8.0 and int_var1 < int_limit then
        int_var1:=int_var1+1;
    elseif array_input_var1[0] <8.0 and int_var1 > 1 then
        int_var1:=int_var1-1;
    else
         int_var1:=0;
    end if;

    if real_var1 > 5.0 and int_var1 >1 then
        bool_var1 := true;
    else
        bool_var1 := false;
    end if;

    output_var1 := array_input_var1[1] + real_var1;

end model_name

The code above may not make too much sense but it is just to give an idea. The main problem is with the discrete variables. Also the block inputs and outputs are connected with other blocks. Its is part of a bigger model.

When I try to export I receive the following error:

[Absyn::0:0-0:0] Internal error: ClassifyEquations.buildContinuousSystem: Expected non-discrete-valued variables to be continuous-valued: bool_var1 (DAELowTypes.DISCRETE_TIME{ state = false; }))

Variable name changed to match the code example. and If I comment the boolean variable i have an error with the integer variable:

[Absyn::0:0-0:0] Internal error: SimCodegen.generateNonlinearSystemSingleAlgorithmResidual: Discrete-valued algorithm outputs not matched to algorithm: int_var1

Again variable name changed to match the code example. I also tried to put the discrete keyword before the boolean and integer variables, but it didn't help. Any ideas of what is causing this problem ?

System information:

Product version: 12.1.0.8
Client: Model Center
Client version: 12.1.0.30
Client creation date: 2020-03-02T13:38:32.855263
Client build revisions: S:2b715d78e, J:6a53ed2a2, L:41ddb1b72
Client build type: 64 bit
Kernel version: 12.1.0.34
Kernel creation date: 2020-03-02T13:39:13.038056
Kernel build revisions: S:2b715d78e, J:6a53ed2a2, L:41ddb1b72
Platform: Ubuntu 14.04.6 LTS

POSTED BY: Michel Oliveira
3 Replies

Good to hear. Even though the update fixed your problem, this report helped us identify a corner case problem that will be fixed in the next version. Thanks!

POSTED BY: Henrik Tidefelt

Thanks for the help. I just missed this point in example, but it is not what was causing the problem. Actually for some reason SM version 12.1 couldn't export an FMU for that model, but 12.3 version does! So the update solved my problem.

POSTED BY: Michel Oliveira

There seems to be a confusion regarding array indexing. Modelica uses 1-based indexing of arrays, so expressions like these are problematic: array_input_var1[0]. If I change index 1 to 2, index 0 to 1, and set int_limit = 3, then the block simulates fine with a recent version of System Modeler. I could also successfully perform FMI 2 CS export of the block. How does that work for you?

POSTED BY: Henrik Tidefelt
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract