Opened 8 years ago

Closed 7 years ago

#4426 closed defect (worksforme)

Flattening error for replaceable modell

Reported by: Niklas Worschech Owned by: somebody
Priority: high Milestone: 2.0.0
Component: Frontend Version:
Keywords: replaceable package Cc: Adrian Pop, Per Östlund, Andreas.Hofmann7@…

Description (last modified by Niklas Worschech)

For the attached modell the omc stops with the following error

Error: Class fluidWorld2.calcRho could not be found in scope of Testlib.Component (looking for a function or record).
Error: Error occurred while flattening model Testlib.test

Is this because of the use of replaceable package?

package Testlib
  model World
    replaceable package Fluid = Testlib.Fluids.BaseFluid constrainedby
      Testlib.Fluids.partialFluidPackage;
    //extends Fluid.FluidParameters;
    // function to calculate Rho
    function calcRho = Fluid.calcRho;
    annotation (defaultComponentName="fluidWorld2",
      defaultComponentPrefixes="inner",
      missingInnerMesage = "You will need  a World componend within the model!",Icon(coordinateSystem(preserveAspectRatio=false)), Diagram(
          coordinateSystem(preserveAspectRatio=false)));
  end World;
  package Fluids
    partial package partialFluidPackage
    end partialFluidPackage;
    package BaseFluid
     extends Testlib.Fluids.partialFluidPackage;
      record FluidParameters
        parameter Real a = 3;
       end FluidParameters;
      function calcRho
        output Real rho;
      algorithm
        rho :=5;
      end calcRho;
    end BaseFluid;
   package Fluid1
      extends Testlib.Fluids.partialFluidPackage;
      record FluidParameters
        parameter Real b = 33;
       end FluidParameters;
      function calcRho
          output Real rho;
      algorithm
        rho := 8;
      end calcRho;
    end Fluid1;
  end Fluids;
  model Component
    outer Testlib.World fluidWorld2;
    Real p;
    Real rho;
  equation
    p = time;
    rho = fluidWorld2.calcRho();
   end Component;
  model test
    inner World fluidWorld2(redeclare package Fluid = Fluids.Fluid1);
    Component component;
  end test;
end Testlib;

Change History (3)

comment:1 by Niklas Worschech, 8 years ago

Description: modified (diff)

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

Milestone: Future2.0.0

Yes. I propose to let this pattern wait for the new frontend (OM 2.0) where the model works fine:

function fluidWorld2.calcRho
  output Real rho;
algorithm
  rho := 8.0;
end fluidWorld2.calcRho;

class Testlib.test
  Real component.p;
  Real component.rho;
equation
  component.p = time;
  component.rho = fluidWorld2.calcRho();
end Testlib.test;

If this is acceptable, you can close the ticket.

comment:3 by Niklas Worschech, 7 years ago

Resolution: worksforme
Status: newclosed
Note: See TracTickets for help on using tickets.