Opened 8 years ago

Closed 4 years ago

#4012 closed defect (fixed)

replace structure parameter

Reported by: Vitalij Ruge Owned by: somebody
Priority: high Milestone: 1.16.0
Component: New Instantiation Version:
Keywords: Cc: Per Östlund

Description

Follwing example don't replace structure parameter.

loadString("

package redeclareStrucParameter
  model base
    replaceable parameter Integer N = 3;
  Real[N] x(each start = 1.0);
  equation
    for i in 1:N loop
    der(x[i]) = 0;
  end for;
  end base;
  
  model B
    extends base(redeclare parameter Integer N = 5);
  end B;
end redeclareStrucParameter;

");

instantiateModel(redeclareStrucParameter.B);

return

"class redeclareStrucParameter.B
  parameter Integer N = 3;
  Real x[1](start = 1.0);
  Real x[2](start = 1.0);
  Real x[3](start = 1.0);
equation
  der(x[1]) = 0.0;
  der(x[2]) = 0.0;
  der(x[3]) = 0.0;
end redeclareStrucParameter.B;

I would accepted N=5.

Change History (3)

comment:1 by Vitalij Ruge, 8 years ago

Component: *unknown*Frontend

comment:2 by Vitalij Ruge, 8 years ago

Can we add a better error-message?

comment:3 by Per Östlund, 4 years ago

Component: FrontendNew Instantiation
Milestone: Future1.16.0
Resolution: fixed
Status: newclosed

The new frontend gives:

class redeclareStrucParameter.B
  final parameter Integer N = 5;
  Real x[1](start = 1.0);
  Real x[2](start = 1.0);
  Real x[3](start = 1.0);
  Real x[4](start = 1.0);
  Real x[5](start = 1.0);
equation
  der(x[1]) = 0.0;
  der(x[2]) = 0.0;
  der(x[3]) = 0.0;
  der(x[4]) = 0.0;
  der(x[5]) = 0.0;
end redeclareStrucParameter.B;
Note: See TracTickets for help on using tickets.