Opened 6 years ago

Closed 5 years ago

#5342 closed defect (fixed)

Issue with Complex array parameter binding in the NF

Reported by: Francesco Casella Owned by: Per Östlund
Priority: blocker Milestone: 1.16.0
Component: New Instantiation Version:
Keywords: Cc: dr.christian.kral@…

Description

Please check HanserModelica.Machines.TestDoubleLayer7over9. The code generation fails with

[/var/lib/hudson/slave/workspace/OpenModelica_TEST_LIBS/OpenModelica/OMCompiler/Compiler/SimCode/SimCodeUtil.mo:5648:7-5648:48:writable] Error: Internal error solving array equation: 1 : N = HanserModelica.Machines.Functions.complexTurns(winding)
for variable: N[1].im.
[OpenModelica/OMCompiler/Compiler/SimCode/SimCodeUtil.mo:1398:5-1398:77:writable] Error: 
Internal error createEquationsForSystems failed
[OpenModelica/OMCompiler/Compiler/SimCode/SimCodeUtil.mo:666:5-666:146:writable] Error:
Internal error function createSimCode failed
[Transformation from optimised DAE to simulation code structure failed]

The reason of the failure is that the binding equation

parameter Real effectiveTurns[winding.m] = Modelica.ComplexMath.'abs'(N);

is moved into the initial equation section, where the BE cannot handle it properly.

@perost, do you think that we could try to somehow expand this binding equation in the frontend without moving it to the initial equations, or should we rather try to fix the backend?

Change History (4)

comment:1 by Per Östlund, 6 years ago

I think you mean that the binding equation

parameter Complex[winding.m] N = HanserModelica.Machines.Functions.complexTurns(winding);

is moved to an equation.

The current logic is that a complex binding is evaluated if either the component or the binding is constant or structural parameter, or if the component is a final parameter. In this case none of those cases is true, so the binding is moved instead.

However, winding is a record instance where every field is final, so I guess the whole record instance might as well be considered final. From that perspective it would make sense to evaluate the binding also in this case. final parameter is not a variability that the NF uses though, so we'll have to add some logic to decide whether a binding expression is safe to evaluate or not (i.e. that it doesn't contain any non-final non-structural parameter). But that should be easy enough to implement.

in reply to:  1 comment:2 by Francesco Casella, 6 years ago

Replying to perost:

I think you mean that the binding equation

parameter Complex[winding.m] N = HanserModelica.Machines.Functions.complexTurns(winding);

is moved to an equation.

Of course, sorry, I pasted the wrong line of code.

The current logic is that a complex binding is evaluated if either the component or the binding is constant or structural parameter, or if the component is a final parameter. In this case none of those cases is true, so the binding is moved instead.

However, winding is a record instance where every field is final, so I guess the whole record instance might as well be considered final. From that perspective it would make sense to evaluate the binding also in this case. final parameter is not a variability that the NF uses though, so we'll have to add some logic to decide whether a binding expression is safe to evaluate or not (i.e. that it doesn't contain any non-final non-structural parameter). But that should be easy enough to implement.

Sounds good. I guess that's also WWDD. Please go ahead.

comment:3 by Francesco Casella, 6 years ago

Priority: highblocker

comment:4 by Francesco Casella, 5 years ago

Milestone: 2.0.01.16.0
Resolution: fixed
Status: newclosed

Now the system passes the frontend, but generates an error in the backend after calling PartitionIndependentBlocks.

Note: See TracTickets for help on using tickets.