Rohit_D
Rohit_D

Reputation: 85

How to work around array of components with fixed size error?

I have a class with a port of dimensions [x,y] which is connected to another class having a matching port. Now I want to provide value to these variables [x,y] through external function call in which I basically read a .xml file and obtain values for x and y. But Dymola gives an error for this since during compilation it comes out as a non fixed size array.

Screenshot of error is attached.enter image description here

Upvotes: 1

Views: 255

Answers (2)

Hans Olsson
Hans Olsson

Reputation: 12527

This should be improved in Dymola 2017 (without the need for modifying the Modelica code). In earlier versions of Dymola it should work if the you translate the C-functions called to compute nTube and nSeg.

If that does not help your complete code would be needed to analyze the problem.

Upvotes: 3

Adrian Pop
Adrian Pop

Reputation: 4231

The array sizes are structural parameters and they usually cannot depend on external function calls because they should be known at compile time. This is however supported in for example OpenModelica where a dll of the external function is built and called and the results are fetched during model compilation.

The only way to support this in all tools is to generate the model using an external tool which reads the xml and changes the .mo file with the values read. You could probably have something like Parameters.mo:

package Parameters
  constant Integer nTube = <EXTERN_NTUBE>;
  constant Integer nSeg = <EXTERN_NSEG>;
end Parameters;

and your external tool will read the XML and bind and in Parameters.mo which you can then use in your models via Parameters.nTube and Parameters.nSeg. Maybe it would be good to give some defaults so that it works to use this file directly:

package Parameters
  constant Integer nTube = 1;
  constant Integer nSeg = 2;
end Parameters;

and then your external tool will replace 1 and 2 with the needed values before compilation.

Upvotes: 3

Related Questions