Opened 10 years ago

Last modified 10 years ago

#2849 accepted defect

Wrong flattening of "inner outer output"

Reported by: Bernhard Thiele Owned by: Adrian Pop
Priority: high Milestone: Future
Component: Frontend Version: trunk
Keywords: inner outer Cc: Adrian Pop

Description (last modified by Adrian Pop)

In the following model (also attached) the inner variable v declared in model Test is assigned to in model B where it is declared as outer output. B is instantiated in A and A is instantiated in Test. In model A variable v is declared as inner outer output.

package Bug

  model B
    outer output Real v;
  equation
    v = time;
  end B;

  model A
    inner outer output Real v;
    Real y2;
    B b;
  equation
    y2 = v;
  end A;

  model Test
    inner Real v;
    Real y1;
    A a;
  equation
    y1 = v;
  end Test;
  
end Bug;

The model flattens, but the generated system of equations is wrong (therefore, it doesn't simulate). The flattened Modelica is:

class Bug.Test
  Real v;
  Real y1;
  Real a.v;
  Real a.y2;
equation
  a.v = time;
  a.y2 = v;
  y1 = v;
end Bug.Test;

Note that the equality constraint between v and a.v is lost.

Adding an additional constraint, e.g., Real a.v = v would make the flattened code valid. Alternatively, a.v could be substituted by v everywhere.

Attachments (1)

BugInnerOuterOutput.mo (281 bytes ) - added by Bernhard Thiele 10 years ago.

Download all attachments as: .zip

Change History (2)

by Bernhard Thiele, 10 years ago

Attachment: BugInnerOuterOutput.mo added

comment:1 by Adrian Pop, 10 years ago

Cc: Adrian Pop added; adrian.pop@… removed
Description: modified (diff)
Owner: changed from somebody to Adrian Pop
Status: newaccepted
Note: See TracTickets for help on using tickets.