openmodelicainterest  

Re: Array manipulation

Martin Sjölund
Wed, 25 Nov 2009 05:05:34 -0800

Hi Filippo,

I'm currently working on a solution to make the identity function work for parameter inputs. Before this is working, try making modes into a constant.

As far as I can tell, the power operator only works for square matrices.

Also, I had to transpose the matrix before using the diagonal operation.

parameter Real OMq[modes,modes] = diagonal(transpose(omq)[1]);

--
Martin Sjölund

Filippo wrote:
This is what I wolud do with open Modelica: A simple state space model of a simple flexible beam driven by a base motion.

model StateSpaceFlexMG "Flexible body driven with base motion"
////
  import Modelica.Constants;
  constant Real PI = Modelica.Constants.pi;
////
  parameter Integer modes = 5;
  parameter Real PF[modes,1] = {{10.3}, {-5.7}, {20.3}, {1.1}, {0.2}};
  parameter Real freq[modes,1] = {{5.5}, {12.1}, {14}, {25}, {73.6}};
////
  parameter Real om[modes,1] = 2*PI*freq;
  parameter Real omq[modes,1] = om^2;
  parameter Real OMq[modes,modes] = diagonal(omq);
////
  parameter Real fiinp[1,modes] = transpose(PF);
  parameter Integer fiout[modes,modes] = identity(modes);
  parameter Real fi[modes+1,modes] = [fiout;fiinp];
////
  Real a, b, c;
////
equation
////
  a = omq[1,1];
  b = omq[2,1];
  c = omq[3,1];
////
end StateSpaceFlexMG;

But this model don't run !

In particular there is an evident problem in the square operation:
  parameter Real omq[modes,1] = om^2;
in the use of the "diagonal" and "identity" functions:
  parameter Real OMq[modes,modes] = diagonal(omq);
  parameter Integer fiout[modes,modes] = identity(modes);


Could have an help ??