Modelica partial model array

Let be A

a partial model and C

, D

be models that extend A

. Given the model

partial model X
  A a[3];
end X;

      

how can i instantiate X eg. something along the lines

A X.a = {C,D,C};

      

Update . I tried 2 options. One of them -

package P
  partial model A end A;
  model B extends A; end B;
  model C extends A; end C;
  partial model X
    A a[3];
  end X;
  model Y extends X(a={c,b,c});
    B b;
    C c;
  end Y;
end P;

      

which fails with the warning "Can only enter inputs, parameters and default variables, but change a.". Another -

package P
  partial model A end A;
  model B extends A; end B;
  model C extends A; end C;
  partial model X
    replaceable A a[3];
  end X;
  model Y extends X;
    redeclare A a={c,b,c};
    B b;
    C c;
  end Y;
end P;

      

which fails with the error "Component a = {c, b, c}, but previously a = <<Empty →. Components are not identical."

Note that you can do the following.

package P
  partial model A end A;
  model B extends A; end B;
  model C extends A; end C;
  partial model X
    A a[3] = {a1,a2,a3};
    replaceable A a1,a2,a3;
  end X;
  model Y extends X;
    redeclare B a1;
    redeclare C a2;
    redeclare B a3;
  end Y;
end P;

      

But I want to P.X

use a parametric array. Again, the next idea for achieving this doesn't work.

package P
  partial model A end A;
  model B extends A; end B;
  model C extends A; end C;
  partial model X
    parameter Integer N;
    replaceable A a[N] = fill(ai,N);
    A ai;
  end X;
  model Y extends X(N=3);
    redeclare A a[3] = {b,c,b};
    B b;
    C c;
  end Y;
end P;

      

0


source to share


2 answers


Yes. It is illegal to instantiate a partial model without extending it from an untreated model. Perhaps something like this:

model Y
  extend X(a = {C, D, C});
end Y;

      



Then Ya is what you want.

+2


source


AFAIK a partial

means your model cannot be created, so you probably have to extend

X.



+1


source







All Articles