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

Array Indexing

Array Indexing

Hi,

when I use array indexing, OMshell 1.8.1 (rev. 11758) can't correctly count the number of equations of the model. Here is an example:

record Arrays
     parameter Integer   n;
     Modelica.SIunits.Temperature[ n] T_liq_port;
     Modelica.SIunits.Temp_C[ n]  T_degC_liq_port;

    parameter Boolean   includeArrays;
end Arrays;

model loopIndexTester
  parameter Boolean includeArrays = true;
  parameter Integer sizeArrays = 5;
   VerktorSizeNullPkg.Arrays arrayRec(final includeArrays=includeArrays,final n=sizeArrays);
algorithm
    arrayRec.T_liq_port[1:end] := ones(sizeArrays)*30;
//    arrayRec.T_liq_port[1:sizeArrays] := ones(sizeArrays)*30;

    arrayRec.T_degC_liq_port := arrayRec.T_liq_port .- 273.15;
end loopIndexTester;

-------------------

The error message I get:

------------------

    messages = "Simulation failed for model: VerktorSizeNullPkg.loopIndexTester
Error: Too few equations, underdetermined system. The model has 6 equation(s) and 11 variable(s)

------------------

If I perform the assignments using a for loop, the translation and simulation are performed correctly.


Thanks in advance,
Erick

Re: Array Indexing

Hi,

I've come across this error too and it is most disturbing. I've tried several workarounds without success.
So if I can do anything to push it up the developers' todo list, let me know!

   Regards
      Peter

Re: Array Indexing

Hi,

it looks like a error in the handling of algorithms in case of arrays. See dumpdaelow report below. I assume the detection of output and input variables did not work for array symbols.

dumpdaelow:
Variables (11)
=========
1:  arrayRec.T_degC_liq_port[5]:VARIABLE() .loopIndexTester, .Arrays, .Real type: Real [5] indx = -1
2:  arrayRec.T_degC_liq_port[4]:VARIABLE() .loopIndexTester, .Arrays, .Real type: Real [5] indx = -1
3:  arrayRec.T_degC_liq_port[3]:VARIABLE() .loopIndexTester, .Arrays, .Real type: Real [5] indx = -1
4:  arrayRec.T_degC_liq_port[2]:VARIABLE() .loopIndexTester, .Arrays, .Real type: Real [5] indx = -1
5:  arrayRec.T_degC_liq_port[1]:VARIABLE() .loopIndexTester, .Arrays, .Real type: Real [5] indx = -1
6:  arrayRec.T_liq_port[5]:VARIABLE() .loopIndexTester, .Arrays, .Real type: Real [5] indx = -1
7:  arrayRec.T_liq_port[4]:VARIABLE() .loopIndexTester, .Arrays, .Real type: Real [5] indx = -1
8:  arrayRec.T_liq_port[3]:VARIABLE() .loopIndexTester, .Arrays, .Real type: Real [5] indx = -1
9:  arrayRec.T_liq_port[2]:VARIABLE() .loopIndexTester, .Arrays, .Real type: Real [5] indx = -1
10:  arrayRec.T_liq_port[1]:VARIABLE() .loopIndexTester, .Arrays, .Real type: Real [5] indx = -1
11:  $dummy:STATE(fixed = true )  type: Real  indx = -1


Equations (6)
=========
1 : Algorithm no: 0 for inputs: (arrayRec.T_liq_port[5], arrayRec.T_liq_port[4], arrayRec.T_liq_port[3], arrayRec.T_liq_port[2], arrayRec.T_liq_port[1]) => outputs: (arrayRec.T_degC_liq_port[5], arrayRec.T_degC_liq_port[4], arrayRec.T_degC_liq_port[3], arrayRec.T_degC_liq_port[2], arrayRec.T_degC_liq_port[1])
2 : Algorithm no: 0 for inputs: (arrayRec.T_liq_port[5], arrayRec.T_liq_port[4], arrayRec.T_liq_port[3], arrayRec.T_liq_port[2], arrayRec.T_liq_port[1]) => outputs: (arrayRec.T_degC_liq_port[5], arrayRec.T_degC_liq_port[4], arrayRec.T_degC_liq_port[3], arrayRec.T_degC_liq_port[2], arrayRec.T_degC_liq_port[1])
3 : Algorithm no: 0 for inputs: (arrayRec.T_liq_port[5], arrayRec.T_liq_port[4], arrayRec.T_liq_port[3], arrayRec.T_liq_port[2], arrayRec.T_liq_port[1]) => outputs: (arrayRec.T_degC_liq_port[5], arrayRec.T_degC_liq_port[4], arrayRec.T_degC_liq_port[3], arrayRec.T_degC_liq_port[2], arrayRec.T_degC_liq_port[1])
4 : Algorithm no: 0 for inputs: (arrayRec.T_liq_port[5], arrayRec.T_liq_port[4], arrayRec.T_liq_port[3], arrayRec.T_liq_port[2], arrayRec.T_liq_port[1]) => outputs: (arrayRec.T_degC_liq_port[5], arrayRec.T_degC_liq_port[4], arrayRec.T_degC_liq_port[3], arrayRec.T_degC_liq_port[2], arrayRec.T_degC_liq_port[1])
5 : Algorithm no: 0 for inputs: (arrayRec.T_liq_port[5], arrayRec.T_liq_port[4], arrayRec.T_liq_port[3], arrayRec.T_liq_port[2], arrayRec.T_liq_port[1]) => outputs: (arrayRec.T_degC_liq_port[5], arrayRec.T_degC_liq_port[4], arrayRec.T_degC_liq_port[3], arrayRec.T_degC_liq_port[2], arrayRec.T_degC_liq_port[1])
6 : der($dummy) = 0.0

Re: Array Indexing

-fixed in revision 12046

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