Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register

record arrays produce overdetermined system

record arrays produce overdetermined system

Hello,

I have the following problem:

When I define arrays of records within a record,
they produce equations and the following model which needs the containing parameters
cannot be simulated. It works in the Dymola demo version.

Code:



package OMtest

record MyGenericData
  parameter Integer dataOne;
  parameter Integer dataTwo;
end MyGenericData;

record DataSetOne = MyGenericData(dataOne = 1, dataTwo = 2);

record DataSetTwo = MyGenericData(dataOne = 3, dataTwo = 4);

record MyDataArrays
  parameter Integer dimension = 2;

  DataSetOne dataSetOne;
  DataSetTwo dataSetTwo;

  MyGenericData dataArrayOne[dimension] = {dataSetOne, dataSetTwo};

end MyDataArrays;

model MyTestModel

  MyDataArrays myDataArrays;

  Integer oneVariable;

equation
oneVariable = myDataArrays.dataArrayOne[1].dataOne;

end MyTestModel;

end OMtest;



Any idea when this will be fixed? Thanks!
Fritz

Hi again current/smile, I hope nobody is answering here because of Christmas and New Year...

Anyway, this does neither work:

Code:



package OMtest

record MyGenericData
  parameter Integer dataOne = 1;
  parameter Integer dataTwo = 1; 
end MyGenericData;

record DataSetOne = MyGenericData(dataOne = 1, dataTwo = 2);

record DataSetTwo = MyGenericData(dataOne = 3, dataTwo = 4);
 
model MyTestModel2

  DataSetOne dataSetOne;
  DataSetTwo dataSetTwo;

  replaceable MyGenericData dataSetArray[:]={dataSetOne, dataSetTwo};
 
  Integer result;

equation
    result = dataSetArray[1].dataOne;

end MyTestModel2;

model MyTestModel2TestModel

DataSetOne dataSetOne;
DataSetTwo dataSetTwo;

//MyTestModel2 testReplaceable(redeclare MyGenericData dataSetArray = {dataSetTwo, dataSetOne});   // this gives a type mismatch error although there shouldn't be any!

MyTestModel2 testReplaceable2(dataSetArray = {dataSetTwo, dataSetOne});    // this gives no error, only has too many equations for simulating

end MyTestModel2TestModel;


end OMtest;


I would really need this type of code. Any comments are welcome.

Thanks, Fritz

Edited by: zav1984 - Jan-04-12 19:49:01

Re: record arrays produce overdetermined system

hello again,
I finally found out how to solve problem 1 with the overdetermined system. within the record MyDataArrays the keyword parameter has to be used again!!! this works!

Code:


record MyDataArrays
  parameter Integer dimension = 2;

  parameter DataSetOne dataSetOne;

  parameter DataSetTwo dataSetTwo;

  parameter MyGenericData dataArrayOne[dimension] = {dataSetOne, dataSetTwo};

end MyDataArrays;

There are 0 guests and 0 other users also viewing this topic
You are here: