Opened 8 years ago
Closed 5 years ago
#4297 closed defect (fixed)
Sum of complex quantities cannot be handled
Reported by: | Owned by: | Per Östlund | |
---|---|---|---|
Priority: | high | Milestone: | 1.14.0 |
Component: | New Instantiation | Version: | |
Keywords: | Cc: | Adeel Asghar |
Description
Please consider the attached example and check model MutualInductor
. Apparently there occurs an issue with the sum of complex quantities in line 67. The following error is caused:
[MutualInductanceTesting: 67:7-67:52]: Expected a reduction function with type signature ('A,'B) => 'B, but got .sum<function>() => #NORETCALL#.
A similar implementation is made in Modelica.Electrical.MultiPhase.Basic.MutualInductor
with real quantities -- not causing such a problem.
However this issue was caused around the implementation of the following Modelica tickets:
I used
OMEdit 1.12.0~dev-219-g62f7633 Connected to OpenModelica 1.12.0~dev-474-gbd934af Linux Mint 18.1 64 bit
Attachments (1)
Change History (12)
by , 8 years ago
Attachment: | MutualInductanceTesting.mo added |
---|
comment:1 by , 8 years ago
Component: | OMEdit → Code Generation |
---|---|
Owner: | changed from | to
Status: | new → assigned |
comment:2 by , 6 years ago
Component: | Code Generation → New Instantiation |
---|---|
Milestone: | Future → 2.0.0 |
I checked this model with the new front-end -d=newInst
using OMC v1.13.0-dev-1096-g6770e6300. I currently get this error:
[1] 20:02:03 Translation Error [C:/dev/OM64bit/OMCompiler/Compiler/NFFrontEnd/NFTyping.mo: 1107:9-1107:121]: Internal error NFTyping.typeExp got unknown expression: {1, 2, 3, 4}
I guess this issue should eventually be fixed in the new front-end.
comment:3 by , 6 years ago
Owner: | changed from | to
---|
I just opened #5277 on the specific issue with the new front-end. When that is fixed, please try to run this test case with -d=newInst
and report.
comment:4 by , 6 years ago
Quoting @perost in ticket:5277#comment:4:
This is based on 10.3.4.1 in the Modelica specification that explicitly says that the argument of a sum reduction must be an Integer or Real expression.
One might expect that the reduction operators would work on operator records with the appropriate operator too, but this is not specified anywhere.
This has already been addressed in Modelica 3.5, see ticket #1897 of the Modelica issue tracker. The resolution was to allow operator records defining '+'
and '0'
in sum()
reduction expressions.
I did quickly check what would happen if the NF actually allowed it, and the model actually passed the backend but failed during compilation since I didn't change the fold expression we generate (i.e. it was still trying to use
+
instead of the'+'
-operator from Complex).
Since there is a user requirement from Christian to have this feature, and this has already been decided upon by the MAP-LANG group and will appear in Modelica 3.5, I would suggest you allow this, and also change the fold expression, so that the following test case works:
model M Complex z[3]; Complex s1 = sum(z); Complex s2 = sum(z[i] for i in 1:2); Complex s3 = sum(z[i]*z[i] for i in 1:2); equation z[1] = Complex(1); z[2] = Complex(2,3); z[3] = Complex(0,1); end M;
comment:5 by , 6 years ago
Milestone: | 2.0.0 → 1.14.0 |
---|---|
Owner: | changed from | to
follow-ups: 8 10 comment:7 by , 5 years ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
I tested the originally attached example MutualInductanceTesting.MutualInductorTest
using the current version 3.2.3+build.2~5~g2556186~om2-1
of the Modelica Standard Library (see #5347).
I tried to simulate the example with -d=newInst
but the compilation failed, showing the following error message:
[1] 16:23:05 Translation Error [MutualInductanceTesting: 67:7-67:52]: Expected a reduction function with type signature ('A,'B) => 'B, but got .sum<function>() => #NORETCALL#. [2] 16:23:05 Translation Error Error occurred while flattening model MutualInductanceTesting.MutualInductorTest
What is the reason for failing the simulation?
- The issue is not fully fixed
- The fixed issue is not implemented in my nightly build version of OpenModelica
Connected to OpenModelica 1.14.0~dev-26494-g4d4d809
- I am missing another simulation flag to be used which I am not aware of
comment:8 by , 5 years ago
Replying to Christian Kral <dr.christian.kral@…>:
What is the reason for failing the simulation?
- The issue is not fully fixed
- The fixed issue is not implemented in my nightly build version of OpenModelica
Connected to OpenModelica 1.14.0~dev-26494-g4d4d809
- I am missing another simulation flag to be used which I am not aware of
The issue seems to be d: you're not actually using the NF. The error message you get is specific to the OF, the NF will never print that particular error. If you're using OMEdit you should just need to turn on the "Enable experimental new instantiation phase" in Options->Simulation.
comment:9 by , 5 years ago
Cc: | added |
---|
Which also suggests that we should change the text of that option to
"Enable new front-end"
which is no longer experimental, and also known by that name since more than two years.
@adeas31, could you do that?
comment:10 by , 5 years ago
Replying to Christian Kral <dr.christian.kral@…>:
I tested the originally attached example
MutualInductanceTesting.MutualInductorTest
using the current version3.2.3+build.2~5~g2556186~om2-1
of the Modelica Standard Library (see #5347).
I tried to simulate the example with
-d=newInst
but the compilation failed, showing the following error message:
After switching to the new intantiation phase on OpenModelica, this issue does not occur any more. So this ticket can be closed from my point of view.
comment:11 by , 5 years ago
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
Package demonstrating issue of sum of complex quantities