﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
1594	Some calculations with three-dimensional variables cause errors	Teemu Lempinen	Teemu Lempinen	"Following simulates

{{{
model ArrayTest 
  Real Stock[1,1,1](each fixed = false, each start = 0.0); 
  Real Valve1[1,1,1] = fill(1, 1, 1, 1); 
  Real Valve2[1,1,1] = fill(1, 1, 1, 1); 
equation 
  der(Stock) = - Valve1 - Valve2; 
end ArrayTest; 
}}}

and flattens to 

{{{
class ArrayTest 
  Real Stock[1,1,1](start = 0.0, fixed = false); 
  Real Valve1[1,1,1] = 1.0; 
  Real Valve2[1,1,1] = 1.0; 
equation 
  der(Stock1,1,1) = (-Valve11,1,1) - Valve21,1,1; 
end ArrayTest;
}}}

Following does not simulate 

{{{
model ArrayTest 
  Real Stock[1,1,1](each fixed = false, each start = 0.0); 
  Real Valve1[1,1,1] = fill(1, 1, 1, 1); 
  Real Valve2[1,1,1] = fill(1, 1, 1, 1); 
equation 
  der(Stock) = Valve1 - Valve2; 
end ArrayTest;
}}}

{{{
Error: Error building simulator. Buildlog: The syntax of the command is incorrect.
gcc  -O3 -falign-functions -msse2 -mfpmath=sse   -I\""C:/OpenModelica1.7.0//inclu 
de/omc\"" -I.    -c -o ArrayTest.o ArrayTest.c 
ArrayTest.c: In function `functionODE': 
ArrayTest.c:321: error: invalid lvalue in unary `&' 
ArrayTest.c: In function `functionDAE': 
ArrayTest.c:389: error: invalid lvalue in unary `&' 
\MinGW
bin
mingw32-make: *** ArrayTest.o Error 1 
}}}

And flattens strangely to 

{{{
class ArrayTest 
  Real Stock[1,1,1](start = 0.0, fixed = false); 
  Real Valve1[1,1,1] = 1.0; 
  Real Valve2[1,1,1] = 1.0; 
equation 
  der(Stock1,1,1) = ({Valve11,1,1} - {Valve21,1,1})[1]; 
end ArrayTest; 
}}}
The flattened model basically seems right, but a little too complex. I don't know where the actual problem is, but the simulations will not work.

The problem appears or dissappears with different operator combinations. 
The follwing combinations work and flatten nicely

{{{
  der(Stock) = Valve1 .* Valve2; 
  der(Stock) = - Valve1 - Valve2; 
  der(Stock) = Valve1 ./ Valve2; 
  der(Stock) = - Valve1 + Valve2; 
  der(Stock) = - Valve1 + Valve2 + Valve1 + Valve2;
}}}
But the following do not 
{{{
  der(Stock) = Valve1 + Valve2; 
  der(Stock) = Valve1 - Valve2;
}}}
The problem is quite urgent for us, since we need three-dimensional arrays for a model in the OpenProd  project."	defect	closed	high			1.7.0	fixed		Teemu Lempinen
