Opened 13 years ago
Closed 13 years ago
#2057 closed defect (fixed)
Problems with ones() and size() in start attributes
| Reported by: | Francesco Casella | Owned by: | Per Östlund |
|---|---|---|---|
| Priority: | high | Milestone: | 1.9.0 |
| Component: | Frontend | Version: | trunk |
| Keywords: | Cc: |
Description
The following model replicates a construct used in the ThermoPower library
"model TestMatrixStart
parameter Integer N = 4,nX = 3;
parameter Real Xstart[nX] = {0.1,0.8,0.1};
Real Xtilde[N,nX](start = ones(size(Xtilde, 1), size(Xtilde, 2)),
each stateSelect = StateSelect.prefer);
equation
for i in 1:N loop
for j in 1:nX loop
der(Xtilde[i,j]) = 1;
end for;
end for;
end TestMatrixStart;
The following error is produced when trying to simulate it:
[TestMatrixStart.mo:6:7-6:51:writable] Error: Wrong type or wrong number of arguments to ones(size(Xtilde, 1), size(Xtilde, 2))'. (in component <NO COMPONENT>)
Apparently, something goes wrong with the evaluation of the start attribute expression. In fact, the original model contains a slightly more complex expression for the start attribute:
model TestMatrixStart2
parameter Integer N = 4,nX = 3;
parameter Real Xstart[nX] = {0.1,0.8,0.1};
Real Xtilde[N,nX](start = ones(size(Xtilde, 1), size(Xtilde, 2)) *
diagonal(Xstart[1:nX]),
each stateSelect = StateSelect.prefer);
equation
for i in 1:N loop
for j in 1:nX loop
der(Xtilde[i,j]) = 1;
end for;
end for;
end TestMatrixStart2;
and also fails due to the same error.
Note:
See TracTickets
for help on using tickets.

This is now fixed in r15116.