- Index
- » Developer
- » OpenModelica development
- » Array Indexing
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,
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
- Index
- » Developer
- » OpenModelica development
- » Array Indexing