Opened 13 years ago
Closed 10 years ago
#1531 closed defect (fixed)
expanding array equation in when clauses
Reported by: | wbraun | Owned by: | lochel |
---|---|---|---|
Priority: | high | Milestone: | |
Component: | Backend | Version: | |
Keywords: | Cc: | wbraun |
Description
The following does not work, while the comment stuff does:
function f input Real[:] a; output Real[size(a,1)] b; algorithm for i in 1:size(a,1) loop b[i] := a[i] + 1; end for; end f; model ArrayWhenFunction parameter Real a[3]={3,1,2}; //parameter Real a1[3]={3,1,2}; //parameter Real b[3]={1,1,1}; Real res[3]; Real x(start =1); equation der(x) = x; when time > 0.5 then res = f(a); //res = a1+b; end when; end ArrayWhenFunction;
All array's are expand, beside the lhs in a when clause.
I'm not sure has this to be done in while the instantiation or in the Backend while create the BackendDAE structure.
My guess is while the instantiation, because all other expression are also expanded there:
$ omc ../Modelica/FunctionWhen.mo function f input Real[:] a; output Real[size(a,1)] b; algorithm for i in 1:size(a,1) loop b[i] := 3.0 + a[i]; end for; end f; class ArrayWhenFunction parameter Real a[1] = 3.0; parameter Real a[2] = 1.0; parameter Real a[3] = 2.0; Real res[1]; Real res[2]; Real res[3]; Real x(start = 1.0); equation der(x) = x; when time > 0.5 then res = f({a[1],a[2],a[3]}); end when; end ArrayWhenFunction;
Change History (5)
comment:1 Changed 13 years ago by sjoelund.se
comment:2 Changed 13 years ago by wbraun
yes, it seems so.
comment:3 Changed 11 years ago by sjoelund.se
- Cc changed from wbraun, to wbraun
- Component set to Backend
This now fails code generation (pre(array)?)
comment:4 Changed 10 years ago by wbraun
- Owner changed from wbraun to lochel
- Status changed from new to assigned
Now it works, although only with numerical initialization.
Notification: The given system is mixed-determined. [index > 0] Notification: The given system is mixed-determined. [index > 1] Notification: The given system is mixed-determined. [index > 2] Notification: The given system is mixed-determined. [index > 3] Warning: No system for the symbolic initialization was generated. A method using numerical algorithms will be used instead.
comment:5 Changed 10 years ago by lochel
- Resolution set to fixed
- Status changed from assigned to closed
This got fixed in the meantime.
This is just a problem with the equation count, right?