Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#4795 closed defect (fixed)

Flattening error for a model with substructure

Reported by: Niklas Worschech Owned by: Martin Sjölund
Priority: critical Milestone: 1.13.0
Component: Frontend Version:
Keywords: flattening error Cc: Bernd.Schmidt6@…

Description

if we use this model

model SimpleModelWithSubstructure
  parameter Real qNom[:, 2] = [0.0, 0.0001; 5.0, 0.001; 10.0, 0.01];
  parameter Integer n = size(qNom, 1);  
  parameter Real dhydMax[n, 1] = [{Modelica.Math.Nonlinear.solveOneNonlinearEquation(function dhydCalc(qNom = qNom[i, 2]), 0, 1e-1, 1e-13) for i in 1:n}];  
  function dhydCalc 
    extends Modelica.Math.Nonlinear.Interfaces.partialScalarFunction;
    input Real qNom;
  algorithm
    y := u - 1e-3;
  end dhydCalc;
end SimpleModelWithSubstructure;

inside a other model

model SimpleModelWithSubstructure_TC01
  SimpleModelWithSubstructure simpleModelWithSubstructure1;
end SimpleModelWithSubstructure_TC01;

we got the error:
Error occurred while flattening model SimpleModelWithSubstructure_TC01
The model for itself alone can be translated.
With the flags
-d=failtrace --showErrorMessages
we got the attached log file

Attachments (2)

Log_SimpleModelWithoutSubstructure.txt (13.0 KB ) - added by Niklas Worschech 7 years ago.
Log_SimpleModelWithSubstructure.txt (15.6 KB ) - added by Niklas Worschech 7 years ago.

Download all attachments as: .zip

Change History (10)

by Niklas Worschech, 7 years ago

comment:1 by Francesco Casella, 7 years ago

Have you tried with -d=newInst?

comment:2 by Niklas Worschech, 7 years ago

if we use -d=newInst this leads to the error:
[Modelica.Math.Nonlinear:410:5-410:46]: Invalid type prefix 'input' on component y, due to existing type prefix 'output'.

by Niklas Worschech, 7 years ago

comment:3 by Francesco Casella, 7 years ago

Component: FrontendNew Instantiation
Milestone: Future2.0.0
Owner: changed from somebody to Per Östlund

comment:4 by Martin Sjölund, 7 years ago

Component: New InstantiationFrontend
Milestone: 2.0.01.13.0
Owner: changed from Per Östlund to somebody

The problem in the new instantiation is that an input argument that is a partial function gets the input prefix propagated to the components of the function itself. Which is wrong; but the new instantiation does not support function partial application yet, right? (Do we have a ticket for that? The new instantiation ticket of language features, etc)

I don't agree with changing this to the new instantiation since the error-message there is totally different from this ticket and the actual error in this ticket would likely not appear in the new instantiation.

comment:5 by Martin Sjölund, 7 years ago

The problem seems to be that we cannot prefix the partial function application. Unless it appears on the top-level (because then there is nothing to prefix). I will make that failtrace an internal error instead because prefixing an expression must never fail.

comment:6 by Martin Sjölund, 7 years ago

Owner: changed from somebody to Martin Sjölund
Status: newaccepted

comment:7 by Martin Sjölund, 7 years ago

Resolution: fixed
Status: acceptedclosed

Fixed with 47aed5e

in reply to:  4 comment:8 by Francesco Casella, 7 years ago

Replying to sjoelund.se:

I don't agree with changing this to the new instantiation since the error-message there is totally different from this ticket and the actual error in this ticket would likely not appear in the new instantiation.

The rationale was that maybe the problem was already fixed in the new frontend, provided that other issues were solved. Of course if you have time to solve this in the old frontend (as it turned out to be the case) I'm just happy :)

Note: See TracTickets for help on using tickets.