- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » How to defined conditional Array...
How to defined conditional Array dimension
How to defined conditional Array dimension
I have tried to fit the size of an array depending on a boolean :
The error message is :
[1] 09:04:41 Traduction Erreur
[Test16: 16:5-16:14]: Could not evaluate structural parameter (or constant): N which gives dimensions of array: A. Array dimensions must be known at compile time.
package Test16
model R1
parameter Integer N (fixed = false) ;
parameter Boolean iB = true ;
equation
if iB then
N = 3 ;
else
N = 1 ;
end if ;
end R1;
model R2
extends R1;
Real x ;
Real A[N];
equation
x = 2.;
end R2;
end Test16;
Re: How to defined conditional Array dimension
Like the error message says the array dimension must be defined at compile time, not by an equation system that's solved during initialization/simulation. So for example:
Code:
model R1
parameter Integer N = if iB then 3 else 1;
parameter Boolean iB = true ;
end R1;
- perost
- 114 Posts
Re: How to defined conditional Array dimension
You seem to be quite new with Modelica and OpenModelica. The book Modelica by Example from Dr. Michael M. Tiller gives a good introduction to Modelica and answers most questions you may have.
- AnHeuermann
- 52 Posts
- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » How to defined conditional Array...