Message Boards Message Boards

0
|
7528 Views
|
1 Reply
|
1 Total Likes
View groups...
Share
Share this post:

Why can input connectors for blocks not have flexible array sizes?

(cross-posted on StackOverflow)

Unspecified array dimensions using [:] are very important to write flexible components for frequent reuse. While I am aware, that the actual size of an array has to be determined at the time a model is compiled, I was having the opinion that this can be done by binding a variable with a definite dimension to one with an unspecified one.

The following simple example for a block VectorSum that is to sum a vector input will not work:

package VectorFunctions

  model Test
      VectorSum converter "Component taking the sum of a vector input";
      InformationSource source "Vector input";
    equation
      connect( source.y, converter.u );
  end Test;

  block VectorSum "Take the sum of an input with unspecified dimension"
      Modelica.Blocks.Interfaces.RealInput u[:];
      Modelica.Blocks.Interfaces.RealOutput y;
    equation
      y = sum(u);
  end VectorSum;

  block InformationSource "Provide some vector output"
      Modelica.Blocks.Interfaces.RealOutput y[3];
    equation
      y = ones( 3 );
  end InformationSource;

end VectorFunctions;

Why does this not work out (after all the dimension for u should be clear from the connect statement as the dimension of the input array is a constant)? What other way to do something like this is there?

Edit:

I changed inputs and outputs into connectors so that the use of connect is cleaner. The Modelica Specs imo are not so clear about this as Section 10.2 Flexible Array Sizes simply points to Section 12.4.5 where this is discussed for functions. Functions according to the specs explicitly allow the above use of unspecified array dimensions for inputs. Since blocks share quite a bit with functions I am not seeing a good reason for this not to work out.

Hi, I agree with your interpretation, I think we should support it. I have filed a bug to keep track of this issue internally, unfortunately I do not see any work around. We will come back to you when we have fixed this problem.

POSTED BY: Quentin Lambert
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