Search code examples
modelicaopenmodelica

Modelica arrays with unspecified dimension


Given a model with an array x of connectors where its size is unspecified, e.g.

connector con
...
end con;

model test
con x[:];
end test;

How can x be instantiated with a specific size, e.g. something like this?

test t(x = ?);
...
equation
connect(t.x[1], a);
connect(t.x[2], b);
...

Solution

  • Why do you need unspecified dimension? You can do something like this:

    connector con
    ...
    end con;
    
    model test
     constant Integer dim = 1;
     con x[dim];
    end test;
    
    // usage
    test(dim = 10);
    ...
    equation
      connect(t.x[1], a);
      connect(t.x[2], b);
    ...