Opened 3 years ago

Closed 3 years ago

#5382 closed defect (fixed)

Errors in delay operator handling

Reported by: aramle Owned by: Jesper Mattsson
Priority: major Milestone:
Component: FMU/JMU runtime Version: trunk
Keywords: Cc:

Description

When we have a constant as input for the delay operator (as compared to e.g. a step) we delay by max_delay instead of delay_time.

This is due to different third input jmi_delay_init

 jmi_delay_init(jmi, 0, JMI_TRUE, JMI_FALSE, _variableDelay_delayMax_0, _trapezoid_y_15);

which is set to true in case of a constant.

model DelayProblem1
  Modelica.Blocks.Nonlinear.VariableDelay variableDelay(delayMax=2)
    annotation (Placement(transformation(extent={{-22,30},{-2,50}})));
  Modelica.Blocks.Sources.Trapezoid trapezoid(
    rising=1,
    width=1,
    falling=1,
    period=4,
    nperiod=1,
    startTime=1)
    annotation (Placement(transformation(extent={{-74,36},{-54,56}})));
  Modelica.Blocks.Sources.Step step(startTime=10, offset=0.1)
    annotation (Placement(transformation(extent={{-78,-44},{-58,-22}})));
equation
  connect(trapezoid.y, variableDelay.u) annotation (Line(points={{-53,46},{-38,
          46},{-38,40},{-24,40}}, color={0,0,127}));
  connect(step.y, variableDelay.delayTime) annotation (Line(points={{-57,-33},{
          -57,0.5},{-24,0.5},{-24,34}}, color={0,0,127}));
  annotation (uses(Modelica(version="3.2.2")));
end DelayProblem1;


model DelayProblem2
  Modelica.Blocks.Nonlinear.VariableDelay variableDelay(delayMax=2)
    annotation (Placement(transformation(extent={{-22,30},{-2,50}})));
  Modelica.Blocks.Sources.Trapezoid trapezoid(
    rising=1,
    width=1,
    falling=1,
    period=4,
    nperiod=1,
    startTime=1)
    annotation (Placement(transformation(extent={{-74,36},{-54,56}})));
  Modelica.Blocks.Sources.Constant step(k=0.1)
    annotation (Placement(transformation(extent={{-78,-44},{-58,-22}})));
equation
  connect(trapezoid.y, variableDelay.u) annotation (Line(points={{-53,46},{-38,
          46},{-38,40},{-24,40}}, color={0,0,127}));
  connect(step.y, variableDelay.delayTime) annotation (Line(points={{-57,-33},{
          -57,0.5},{-24,0.5},{-24,34}}, color={0,0,127}));
  annotation (uses(Modelica(version="3.2.2")));
end DelayProblem2;

Change History (3)

comment:1 Changed 3 years ago by Jesper Mattsson

As far as I can tell, the third argument is supposed to be true in case of a constant. The problem is that the implementation in jmi_delay.c discards the delay time in favor of the max delay time if it was specified as fixed in the initialization call. While this is somewhat reasonable, it is not documented anywhere.

I'll change the code generation to match the actual behavior instead of the documented behavior and update the documentation.

comment:2 Changed 3 years ago by Jesper Mattsson

Owner: changed from Christian Andersson to Jesper Mattsson
Status: newaccepted

comment:3 Changed 3 years ago by Jesper Mattsson

Resolution: fixed
Status: acceptedclosed

r9936

Fixed delay operator for parameter delay time with max given, and added some missing error checks.

Note: See TracTickets for help on using tickets.