Opened 13 years ago

Closed 11 years ago

#1659 closed defect (fixed)

Redeclare with recursive modifier doesn't work

Reported by: Per Östlund Owned by: Per Östlund
Priority: high Milestone:
Component: Instantiation Version:
Keywords: Cc: Per Östlund, Adrian Pop

Description

Several Fluid models use StaticPipe, which both redeclares Medium and sets a modifier on the flowModel component that uses flowModel itself. If Medium is redeclared to be a medium which redeclares density in this case, then we get a type mismatch when the modifier is elaborated. This is caused by flowModel.states not having been updated to the correct ThermodynamicState class. Medium.density therefore gets the type of it's input to be PartialSimpleMedium.ThermodynamicState, as redeclared by OneTank, but flowModel.states will still be PartialMedium.ThermodynamicState since it's type will only be updated when flowModel has been instantiated. Here is a model which shows this problem:

model StaticPipe 
  extends PartialStraightPipe;
  FlowModel flowModel(redeclare final package Medium = Medium, 
    vs = Medium.density(flowModel.states));
end StaticPipe;

partial model PartialStraightPipe 
  replaceable package Medium = PartialMedium;
  replaceable model FlowModel = PartialStaggeredFlowModel;
end PartialStraightPipe;

model PartialStaggeredFlowModel 
  replaceable package Medium = PartialMedium;
  input Medium.ThermodynamicState states;
  input Real vs;
end PartialStaggeredFlowModel;

partial package PartialMedium 
  replaceable record ThermodynamicState 
  end ThermodynamicState;

  replaceable partial function density 
    input ThermodynamicState state;
    output Real d;
  end density;
end PartialMedium;

partial package PartialSimpleMedium 
  extends PartialMedium;

  redeclare record extends ThermodynamicState 
    Real p;
    Real T;
  end ThermodynamicState;

  redeclare function extends density 
  algorithm
    d := 0;
  end density;
end PartialSimpleMedium;

model OneTank 
  StaticPipe pipe(redeclare package Medium = PartialSimpleMedium);
end OneTank;

Change History (1)

comment:1 by Per Östlund, 11 years ago

Cc: perost, adrpo, perost → perost, adrpo
Resolution: fixed
Status: acceptedclosed

This seems to be working now.

Note: See TracTickets for help on using tickets.