Opened 12 years ago

Closed 11 years ago

#2002 closed defect (fixed)

Parameterbinding is lost

Reported by: Christian Schubert Owned by: Adrian Pop
Priority: blocker Milestone: 1.9.0
Component: Frontend Version: trunk
Keywords: lost parameter redeclare Cc: Jens Frenkel, Per Östlund

Description

Hi,

while looking into the division by zero problems, I came across the

Modelica.Fluid.Examples.InverseParameterization

model which fails with

stdout            | warning | division by zero in partial equation: (pipe2.flowModel.m_flows[1] * pipe2.flowModel.dp_nominal) / pipe2.flowModel.m_flow_nominal because pipe2.flowModel.m_flow_nominal == 0: File: /var/lib/hudson/jobs/OpenModelica_MSL_COVERAGE/workspace/OpenModelica/build/lib/omlibrary/Modelica 3.2.1/Fluid/Pipes.mo Line: 2048
stdout            | warning | at Time=0.000000
stdout            | warning | [line] 2505 | [file] Modelica.Fluid.Examples.InverseParameterization.c
assert            | assert  | division by zero

The parameter pipe2.flowModel.m_flow_nominal should not be zero, however, since

  Modelica.Fluid.Pipes.StaticPipe pipe2(
    [...]
    redeclare model FlowModel =
       Modelica.Fluid.Pipes.BaseClasses.FlowModels.NominalLaminarFlow (
        [...]
        m_flow_nominal=1))

when running instantiateModel I get

parameter Real pipe1.flowModel.m_flow_nominal(quantity = \"MassFlowRate\", unit = \"kg/s\") \"Mass flow rate for dp_nominal (for nominal models)\";

So it seems that the (new) binding equation is lost somewhere in the FrontEnd. I ran the model exactly as in the msl32 mos-file so with +d=scodeInstShortcut.

So far I was not able to replicate the problem with a simple test model.

Attachments (2)

ParameterBug.mo (578 bytes ) - added by Christian Schubert 12 years ago.
ParameterBug.mos (647 bytes ) - added by Christian Schubert 12 years ago.

Download all attachments as: .zip

Change History (7)

by Christian Schubert, 12 years ago

Attachment: ParameterBug.mo added

by Christian Schubert, 12 years ago

Attachment: ParameterBug.mos added

comment:1 by Christian Schubert, 12 years ago

Now, I was able to reproduce the problem with a simple testmodel:

model Test
  StaticPipe pipe1(redeclare model FlowModel = PartialGenericPipeFlow (m_flow_nominal=1));
end Test;

model StaticPipe
  replaceable model FlowModel = PartialGenericPipeFlow;
  FlowModel flowModel;
end StaticPipe;

model PartialGenericPipeFlow
  parameter Modelica.SIunits.MassFlowRate m_flow_nominal;
end PartialGenericPipeFlow;

The problem is that instantiateModel(Test) gives

parameter Real pipe1.flowModel.m_flow_nominal;

instead of

parameter Real pipe1.flowModel.m_flow_nominal = 1;

Although the parameter has been modified in the redeclare in the Test model.

comment:2 by Per Östlund, 12 years ago

Cc: Per Östlund added

comment:3 by Christian Schubert, 12 years ago

I just noted, that this seems only occurs with

+d=scodeInstShortcut

(Unfortunately the fluid models (where this problem occurs) cannot be simulated without scodeInstShortcut.)

comment:4 by Adrian Pop, 12 years ago

I've debug this a bit and I know why this happens. I'll see if I can fix it this week (as I'm in holidays).

comment:5 by Adrian Pop, 11 years ago

Resolution: fixed
Status: newclosed

This works fine without the +d=scodeInstShortcut flag which should be deprecated soon.

Note: See TracTickets for help on using tickets.