Opened 10 years ago

Closed 6 years ago

Last modified 6 years ago

#3089 closed defect (fixed)

Flattening error concerning records of records

Reported by: Francesco Casella Owned by: Per Östlund
Priority: critical Milestone: 2.0.0
Component: New Instantiation Version: trunk
Keywords: Cc:

Description

Consider the attached Save Total file. When compiling, eventually OMC issues the following error:

[D:/Temp/CentrifugalPumpTotal.mo:2682:9-2682:64:writable] Error: Variable sat.liq.d not found in scope Cryogenics.Components.CentrifugalPump$pump.Medium.setSat_p

Now, pump.Medium is Cryogenics.Media.HeliumHelmholtz, which extends HelmholtzMedia.HelmholtzFluids.Helium, which extends Interfaces.PartialHelmholtzMedium, which contains the two declarations

  redeclare record extends ThermodynamicState(phase(start=0))
    // inherits phase integer
    Temperature T "Temperature of medium";
    AbsolutePressure p "Absolute pressure of medium";
    Density d "Density of medium";
    SpecificEnergy u "Specific inner energy of medium";
    SpecificEnthalpy h "Specific enthalpy of medium";
    SpecificEntropy s "Specific entropy of medium";
  end ThermodynamicState;

  redeclare record extends SaturationProperties
    // inherits Tsat and psat
    ThermodynamicState liq;
    ThermodynamicState vap;
  end SaturationProperties;

and the redeclaration of setSat_p containing the offending statement:

redeclare function setSat_p 
  input AbsolutePressure p;
  output SaturationProperties sat;
...
algorithm
...
  sat.liq.d := 1.02*Ancillary.bubbleDensity_T(T=sat.Tsat);

According to the above declarations, sat.liq.d and sat.vap.d should be well-defined.

The model compiles and runs in Dymola.

Attachments (4)

CentrifugalPumpTotal.zip (161.2 KB ) - added by Francesco Casella 10 years ago.
Save Total file
MiniMedium.zip (1.0 KB ) - added by m.thorade@… 10 years ago.
very simple Medium with record of records
test.mos (190 bytes ) - added by Francesco Casella 10 years ago.
mos script for omc
Ancillary_StartValues.mo (226.4 KB ) - added by A.Taeschner@… 10 years ago.
Extremely reduced test case based on HelmholtzMedia.Examples.ConvergenceTest.Ancillary_StartValues

Download all attachments as: .zip

Change History (18)

by Francesco Casella, 10 years ago

Attachment: CentrifugalPumpTotal.zip added

Save Total file

comment:1 by Martin Sjölund, 10 years ago

Milestone: 1.9.21.9.3

Milestone changed to 1.9.3 since 1.9.2 was released.

comment:2 by m.thorade@…, 10 years ago

I was not able to open the Save Total File in OpenModelica, there were some warnings (it did open in Dymola), but the error about not finding sat.liq.h or some other variables can as well be reproduced by running any of the examples from HemlholtzMedia, e.g. HelmholtzMedia.Examples.BranchingDynamicPipes

Flattening records of records seems to work in simpler examples (see attached example MiniMedium), so I am unsure what exactly goes wrong in the more complex case.

by m.thorade@…, 10 years ago

Attachment: MiniMedium.zip added

very simple Medium with record of records

by Francesco Casella, 10 years ago

Attachment: test.mos added

mos script for omc

comment:3 by Francesco Casella, 10 years ago

The save total works for me, just invoke omc from the command line with the attached .mos script

by A.Taeschner@…, 10 years ago

Attachment: Ancillary_StartValues.mo added

Extremely reduced test case based on HelmholtzMedia.Examples.ConvergenceTest.Ancillary_StartValues

comment:4 by A.Taeschner@…, 10 years ago

Added test case which was produced from a save total of the HelmholtzMedia.Examples.ConvergenceTest.Ancillary_StartValues model. Using omc it produces the same error message as for the original test case, but it should be easier to debug.

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

Milestone: 1.9.31.9.4

Moved to new milestone 1.9.4

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

Milestone: 1.9.41.9.5

Milestone pushed to 1.9.5

comment:7 by Alexander Täschner <A.Taeschner@…>, 9 years ago

Using the latest nightly build (OpenModelica-v1.9.5-dev-13-g0fe3fc5.exe) on windows the CentrifugalPumpTotal model still errors out with the same error message as reported by the OP.

comment:8 by Martin Sjölund, 9 years ago

Milestone: 1.9.51.10.0

Milestone renamed

comment:9 by Martin Sjölund, 8 years ago

Milestone: 1.10.01.11.0

Ticket retargeted after milestone closed

comment:10 by Martin Sjölund, 8 years ago

Milestone: 1.11.01.12.0

Milestone moved to 1.12.0 due to 1.11.0 already being released.

comment:11 by Francesco Casella, 7 years ago

Component: FrontendNew Instantiation
Milestone: 1.12.02.0.0
Owner: changed from Adrian Pop to Per Östlund
Status: newassigned

comment:12 by Matthis Thorade <matthis.thorade@…>, 6 years ago

in reply to:  12 comment:13 by Per Östlund, 6 years ago

Resolution: fixed
Status: assignedclosed

Replying to Matthis Thorade <matthis.thorade@…>:

newInst status:
https://libraries.openmodelica.org/branches/newInst/HelmholtzMedia/HelmholtzMedia.html
Is this the same issue as #5225 ?

No, #5225 is a completely different issue. This ticket is about the old frontend failing to look up a name used in the model, due to redeclare or extends issues. In #5225 the model has passed successfully through both the new frontend and the backend, but the code generator generates invalid code because it can't handle nested records in some cases.

Since all the mentioned models in this ticket seems to work fine with the new frontend I guess we might as well close this ticket. Neither the Cryogenics och Helmholtz models mentioned simulates yet, but that seems to be due to other issues.

comment:14 by anonymous, 6 years ago

Apologies for my limited understanding...
Yes, that sounds like this ticket can be closed.

Note: See TracTickets for help on using tickets.