Using unspecified array dimensions (:
) is an essential feature to design flexible components for reuse. I am well aware that the actual dimension has to be fixed when the model is compiled. To my knowledge binding a variable with unspecified array dimensions to one that has clearly defined dimensions should suffice.
So I am a bit confused why the following model Test
will not validate in either OpenModelica
or the Wolfram System Modeler
:
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;
How can something like this be done then?
I have been given (inofficial) feedback on Wolfram Community by someone from Wolfram MathCore (e.g. the developers of the System Modeler):
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.
So, hopefully flexbile array sizes will be supported for blocks
as they are for functions
.