Opened 13 years ago

Last modified 13 years ago

#1697 closed defect (fixed)

Modelica.Media issues with code generation.

Reported by: Adrian Pop Owned by: Adrian Pop
Priority: high Milestone:
Component: Backend Version:
Keywords: Cc: Adrian Pop, Frenkel TUD, Willi Braun

Description

Francesco C. made a small test for Media (attached).
TestMedia.TestModels.TestWater, TestMedia.TestModels.TestSteam have issues in the code generation.

Attachments (2)

TestMedia.mo (2.0 KB ) - added by Adrian Pop 13 years ago.
TestMedia.mos (904 bytes ) - added by Adrian Pop 13 years ago.

Download all attachments as: .zip

Change History (4)

by Adrian Pop, 13 years ago

Attachment: TestMedia.mos added

comment:1 by Willi Braun, 13 years ago

Actually, the issue is to support records in the Backend.
For example in "TestMedia.TestModels.TestWater" we inline a function parameter to one record expression.

record R1
 Real a;
end R1;

function foo
 input R1 in;
 output R1 out;
algorithm
  out.a := in.a;
end foo;

class A
 parameter R1 r1(a=3.0);
  R1 r2;
equation
  r2 = foo(r1);
end A;

results in

class A
 parameter Real r1.a = 3.0;
 Real r2.a;
equation
 r2.a = in.a;
end A;

Of course "in.a" is here not available in the global scope and that results into the code generation error.

As far as I can see, one easy way to support records in expressions like "rec = f(...)",
is to handle them exactly like tuple-function calls "(out1,out2) = func(...)".
Those are just transformed to algorithms for the Backend issues, this should be easier to
implement than handle them as array equations.

comment:2 by Martin Sjölund, 13 years ago

Well, the inlining should of course take care to replace in.a with r1.a ... Just like it would change in to r1 if it was an Integer...

comment:3 by Jens Frenkel, 13 years ago

solved in revision 11285

Note: See TracTickets for help on using tickets.