Opened 5 years ago

Last modified 3 years ago

#5991 closed defect

NF cannot evaluate structural parameter during NFTyping.typeComponents — at Version 6

Reported by: Francesco Casella Owned by: Per Östlund
Priority: blocker Milestone: 1.18.0
Component: New Instantiation Version:
Keywords: Cc: Andrea Bartolini, Michael Wetter

Description (last modified by Francesco Casella)

There are over 50 models in the Buildings library that fail for the same reason, see, e.g., Buildings.ThermalZones.Detailed.BaseClasses.Examples.InfraredRadiationExchange. The NF reports

[Buildings latest/HeatTransfer/Data/OpaqueConstructions.mo:9:4-11:111:writable]
Error: Could not evaluate structural parameter (or constant): 
irRadExc.datConExt.layers.nLay which gives dimensions of array: material.
Array dimensions must be known at compile time.

There are many other models with the same issue, e.g. Buildings.Examples.ScalableBenchmarks.BuildingVAV.Examples.OneFloor_OneZone. The NF fails with

Error: Internal error 
Instantiation of Buildings.Examples.ScalableBenchmarks.BuildingVAV.Examples.OneFloor_OneZone
failed with no error message.

This issue affects a large number of models in the Buildings libraries, e.g.
https://libraries.openmodelica.org/branches/master/Buildings_latest/files/Buildings_latest_Buildings.ThermalZones.Detailed.Constructions.Examples.ExteriorWall.err
https://libraries.openmodelica.org/branches/master/Buildings_latest/files/Buildings_latest_Buildings.ThermalZones.Detailed.Examples.ElectroChromicWindow.err
https://libraries.openmodelica.org/branches/master/Buildings_latest/files/Buildings_latest_Buildings.ThermalZones.Detailed.Examples.MixedAirCO2.err
Fixing this issue would improve the coverage of Buildings substantially.

Change History (6)

comment:1 by Francesco Casella, 4 years ago

Cc: Andrea Bartolini added

Andrea.Bartolini provided me a MWE to reproduce the same error (also attached)

package TestRecord
  record CalcData
    parameter Integer N = 1;
    Real[N] val;
  end CalcData;

  model M1
    input CalcData calcData;
    Real x[calcData.N];
  equation
    x = calcData.val.^2;
  end M1;

  model M2
    constant Integer Nact = 5;
    CalcData calcVal(N=Nact);
    M1 m1(calcData = calcVal);
  equation
    calcVal.val = fill(time,Nact);
  end M2;
end TestRecord;

When you try to compile M2, you get

[1] 23:01:21 Translation Error
[TestRecord: 4:5-4:16]: Could not evaluate structural parameter (or constant): 
m1.calcData.N which gives dimensions of array: val. 
Array dimensions must be known at compile time.

I suspect the issue is the same that plagues the Building library, which often uses record to hold datasheets, which may contain structural parameters for array dimensions.

As far as I understand this model is perfectly legal. Dymola accepts it also in pedantic mode.

comment:2 by Francesco Casella, 4 years ago

Summary: NF cannot evaluate structural parameterNF cannot evaluate structural parameter during NFTyping.typeComponents

comment:3 by Francesco Casella, 4 years ago

Milestone: 1.17.01.18.0

comment:4 by Francesco Casella, 4 years ago

See also #6126.

comment:5 by Francesco Casella, 4 years ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.