Opened 11 years ago

Closed 6 years ago

#2660 closed defect (fixed)

Lookup bug with replaceable models

Reported by: Francesco Casella Owned by: Per Östlund
Priority: blocker Milestone: 2.0.0
Component: New Instantiation Version: trunk
Keywords: Cc: andrea.bartolini@…

Description

The model ThermoPower.Examples.HRB.Simulators.OpenLoopSimulatorHtc gives this compilation error:

Examples.mo:1439:26-1439:45:writable 
Error: Variable gamma_nom not found in scope ThermoPower.Gas.Flow1DFV.

The offending code reads:

model HeatExchanger
  ...
  parameter CoefficientOfHeatTransfer gamma_nom=150
    "Nominal heat transfer coefficient";
  ...
  Gas.Flow1DFV GasSide(
  ...
  redeclare ThermoPower.Thermal.HeatTransfer.FlowDependentHeatTransferCoefficient
    heatTransfer(gamma_nom=gamma_nom, alpha=0.6),
  ...

As far as I understand, there is a gamma_nom defined in the scope of HeatExchanger, whose value is then passed to the gamma_nom parameter defined in the scope of FlowDependentHeatTransferCoefficient model.

Why does OMC complain about gamma_nom not being defined in the scope of the Flow1DFV model?

Change History (11)

comment:1 by Francesco Casella, 10 years ago

Resolution: fixed
Status: newclosed

The model compiles and simulates successfully in r21001 and has been doing that for a while.

comment:2 by Francesco Casella, 10 years ago

Cc: andrea.bartolini@… added
Milestone: 1.9.11.9.2
Resolution: fixed
Status: closedreopened

We have slightly changed the implementation of the heat transfer, from a replaceable component to a replaceable class from which a model is instatiated (as in the Volume model of Modelica.Fluid). The model now reads:

model HeatExchanger "Base class for heat exchanger fluid - gas"
...
  parameter SI.CoefficientOfHeatTransfer gamma_nom=150 
    "Nominal heat transfer coefficient";
...
  Gas.Flow1DFV GasSide(
    ....
    redeclare model HeatTransfer =
      ThermoPower.Thermal.HeatTransferFV.FlowDependentHeatTransferCoefficient(
        gamma_nom=gamma_nom, alpha=0.6),
...
end HeatExchanger;

Unfortunately, a similar problem has popped up again and is still there in r22966:

Error: Variable gamma_nom not found in scope ThermoPower.Gas.Flow1DFV$Plant$Boiler$GasSide.
Error: Error occurred while flattening model ThermoPower.Examples.HRB.Simulators.OpenLoopSimulatorHtc

The the actual parameter gamma_nom is defined in the scope of HeatExchanger, and the formal parameter gamma_nom is defined in the scope of FlowDependentHeatTransferCoefficient. It is not clear why does the front-end complains about gamma_nom not being in the scope of GasSide, but I guess it is looking in the wrong place...

comment:3 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:4 by Martin Sjölund, 9 years ago

Milestone: 1.9.31.9.4

Moved to new milestone 1.9.4

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

Milestone: 1.9.41.9.5

Milestone pushed to 1.9.5

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

Milestone: 1.9.51.10.0

Milestone renamed

comment:7 by Francesco Casella, 8 years ago

Milestone: 1.10.02.0.0
Priority: highblocker

comment:8 by Francesco Casella, 7 years ago

Component: FrontendNew Instantiation

comment:9 by Francesco Casella, 7 years ago

This is the report with the NF:

[Modelica 3.2.2/Media/Water/package.mo:126:22-126:33:writable]
Error: Type mismatch in binding start = 100000.0, expected subtype of Real[11], got type Real.

I'm not sure if this issue is coming before or after the reported one. I added a comment to#4921 on this topic.

comment:10 by Francesco Casella, 6 years ago

Owner: changed from Adrian Pop to Per Östlund
Status: reopenedassigned

The NF report is now:

[OpenModelica/OMCompiler/build/lib/omlibrary/ThermoPower 3.1/Gas.mo:1166:7-1166:73:writable] 
Error: Internal error NFScalarize.scalarizeEquation could not expand rhs 
Plant.Boiler.GasSide.Xtilde[1, 1:Plant.Boiler.GasSide.nXi]

so I can't still see the flat model and check if the NF processes this model correctly.

comment:11 by Francesco Casella, 6 years ago

Resolution: fixed
Status: assignedclosed

The model now passess the front-end successfully. It later fails in the back-end because of #5163, but that is not related to this issue.

Note: See TracTickets for help on using tickets.