﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
2057	Problems with ones() and size() in start attributes	Francesco Casella	Per Östlund	"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.
"	defect	closed	high	1.9.0	Frontend	trunk	fixed		
