- Index
- » Developer
- » OpenModelica development
- » Problem while iterating on records
Problem while iterating on records
Problem while iterating on records
Hello,
I’m having a quite strange behaviour with OpenModelica while iterating on records. At the beginning I thought it was my fault, but I am receiving also bad calculations from models in Modelica.Media. Is it a known bug or is it my fault? I attach a file with one very simple example. Result is correct in Test1, but not in Test2 or Test3. I’m using OpenModelica 1.13.2 64 bits.
Someone one can help?
Thanks
Re: Problem while iterating on records
This is a known bug (https://trac.openmodelica.org/OpenModelica/ticket/2858) that was fixed in the new front-end. Please use the latest nightly-build:
https://build.openmodelica.org/omc/buil … ly-builds/
Code:
// t.mos
loadFile("Structure.mo"); getErrorString();
simulate(Structure.Test1); getErrorString();
val(A, 1);
simulate(Structure.Test2); getErrorString();
val(A, 1);
simulate(Structure.Test3); getErrorString();
val(A, 1);
With current front-end:
Code:
adrpo33@ida-0030 MINGW64 /c/home/adrpo33/dev/OMTesting/iteration
$ ~/dev/OpenModelica/build/bin/omc t.mos
true
""
record SimulationResult
resultFile = "C:/home/adrpo33/dev/OMTesting/iteration/Structure.Test1_res.mat",
simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 500, tolerance = 1e-006, method = 'dassl', fileNamePrefix = 'Structure.Test1', optio ns = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''",
messages = "LOG_SUCCESS | info | The initialization finished successfully without homotopy method.
LOG_SUCCESS | info | The simulation finished successfully.
",
timeFrontend = 0.0288302,
timeBackend = 0.0440066,
timeSimCode = 0.0084861,
timeTemplates = 0.0655039,
timeCompile = 12.860871,
timeSimulation = 0.53805,
timeTotal = 13.548594
end SimulationResult;
""
15.0
record SimulationResult
resultFile = "C:/home/adrpo33/dev/OMTesting/iteration/Structure.Test2_res.mat",
simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 500, tolerance = 1e-006, method = 'dassl', fileNamePrefix = 'Structure.Test2', optio ns = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''",
messages = "LOG_SUCCESS | info | The initialization finished successfully without homotopy method.
LOG_SUCCESS | info | The simulation finished successfully.
",
timeFrontend = 0.0099308,
timeBackend = 0.0031456,
timeSimCode = 0.0007796,
timeTemplates = 0.0563182,
timeCompile = 12.5935838,
timeSimulation = 0.4877127,
timeTotal = 13.1526335
end SimulationResult;
""
10.0
record SimulationResult
resultFile = "C:/home/adrpo33/dev/OMTesting/iteration/Structure.Test3_res.mat",
simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 500, tolerance = 1e-006, method = 'dassl', fileNamePrefix = 'Structure.Test3', optio ns = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''",
messages = "LOG_SUCCESS | info | The initialization finished successfully without homotopy method.
LOG_SUCCESS | info | The simulation finished successfully.
",
timeFrontend = 0.0203584,
timeBackend = 0.0046265,
timeSimCode = 0.0013041,
timeTemplates = 0.0546605,
timeCompile = 13.1451636,
timeSimulation = 0.5539768000000001,
timeTotal = 13.7813722
end SimulationResult;
""
10.0
With new front-end: -d=newInst
Code:
adrpo33@ida-0030 MINGW64 /c/home/adrpo33/dev/OMTesting/iteration
$ time ~/dev/OpenModelica/build/bin/omc -d=newInst t.mos
true
""
record SimulationResult
resultFile = "C:/home/adrpo33/dev/OMTesting/iteration/Structure.Test1_res.mat",
simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 500, tolerance = 1e-006, method = 'dassl', fileNamePrefix = 'Structure.Test1', optio ns = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''",
messages = "LOG_SUCCESS | info | The initialization finished successfully without homotopy method.
LOG_SUCCESS | info | The simulation finished successfully.
",
timeFrontend = 0.0131841,
timeBackend = 0.0043454,
timeSimCode = 0.0012549,
timeTemplates = 0.0418104,
timeCompile = 10.5543462,
timeSimulation = 0.5015408,
timeTotal = 11.1178179
end SimulationResult;
""
15.0
record SimulationResult
resultFile = "C:/home/adrpo33/dev/OMTesting/iteration/Structure.Test2_res.mat",
simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 500, tolerance = 1e-006, method = 'dassl', fileNamePrefix = 'Structure.Test2', optio ns = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''",
messages = "LOG_SUCCESS | info | The initialization finished successfully without homotopy method.
LOG_SUCCESS | info | The simulation finished successfully.
",
timeFrontend = 0.0012632,
timeBackend = 0.0126055,
timeSimCode = 0.0008018,
timeTemplates = 0.0412061,
timeCompile = 10.63316,
timeSimulation = 0.5010813,
timeTotal = 11.1909594
end SimulationResult;
""
15.0
record SimulationResult
resultFile = "C:/home/adrpo33/dev/OMTesting/iteration/Structure.Test3_res.mat",
simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 500, tolerance = 1e-006, method = 'dassl', fileNamePrefix = 'Structure.Test3', optio ns = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''",
messages = "LOG_SUCCESS | info | The initialization finished successfully without homotopy method.
LOG_SUCCESS | info | The simulation finished successfully.
",
timeFrontend = 0.0043822,
timeBackend = 0.0066643,
timeSimCode = 0.0017293,
timeTemplates = 0.0877218,
timeCompile = 10.6279343,
timeSimulation = 0.5973836,
timeTotal = 11.326688
end SimulationResult;
""
15.0
- adrpo
- 885 Posts
Re: Problem while iterating on records
Thank you very much. I will try.
Carlos
Re: Problem while iterating on records
Hi Adrian,
I installed v1.14.0-dev-26644, that solved the iteration over the array of records for the example given, but I am still having problem when the iteration is over an array of records that contains a Real array inside.
I attach the file. Test21 is OK, but not Test22. The new frontend gives the following error:
[1] 00:08:55 Translation Error
[CodegenCFunctions.tpl: 6583:13-6583:13]: Template error: ASUB non-scalar {{5.0, 50.0}, {10.0, 100.0}}[i]. The inner exp has type: Real[2, 2]. After ASUB it is still an array: Real[2].
The old frontend gives no error, but does a bad calculation.
Am I trying to do something forbidden by the Modelica language?
Carlos
Re: Problem while iterating on records
This is most likely a bug. I made a ticket for it and we will fix it: https://trac.openmodelica.org/OpenModelica/ticket/5616
You can fix this by using:
Code:
A:=A+sum(test[i].Tc);
in Test22.
- adrpo
- 885 Posts
Re: Problem while iterating on records
Thank you again.
In fact there is no problem if you make the iteration manually, by indexing 1,2,...
- Index
- » Developer
- » OpenModelica development
- » Problem while iterating on records