Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#5587 closed defect (fixed)

Bad value for interpolation in delayImpl

Reported by: ni.ding@… Owned by:
Priority: high Milestone: Future
Component: Backend Version: v1.13.2
Keywords: Cc: alireza.masoom@…, adrien.guironnet@…

Description

The following example using delay operator is not properly handled when there is a state event (please see the attached log).

model example_delay

Real x;
Real y;

equation

x = if time < 0.00003 then 0 else 2*Modelica.Math.cos(2

*Modelica.Constants.pi*60*(time));

y = delay(x, 0.00034);

annotation(

OpenModelica_simulationFlags(lv = "LOG_STATS", outputFormat = "csv", s = "trapezoid"),
experiment(StartTime = 0, StopTime = 0.05, Tolerance = 1e-6, Interval = 5e-05));

end example_delay;

In this example, the ring buffer contains values
storeDelayed[0] 0:0 position=1
storeDelayed[0] 5e-005:0 position=2
storeDelayed[0] 3.00001e-005:0 position=3
storeDelayed[0] 5e-005:1.99964 position=4
storeDelayed[0] 0.0001:1.99858 position=5

We have
delayImpl: exprNumber = 0, exprValue = 1.99432, time = 0.00035, delayTime = 0.00034
| | | | | | findTime 1.000000e-005
| | | | | | time(0, 9)[4] = 1.000000e-004
| | | | | | time(0, 4)[2] = 3.000010e-005
| | | | | | time(0, 2)[1] = 5.000000e-005
| | | | | | return time[0, 1] = 5.000000e-005
| | | | | | delayImpl: Linear interpolation of 1e-005 between 0 and 5e-005
| | | | | | delayImpl: Linear interpolation of 1e-005 value: 0 and 0 = 0
Here the value to be used in the interpolation at t=5e-005 should be 1.99964 instead of 0, since the state event has occurred at 3.00001e-005. In other words, storeDelayed[0] 5e-005:0 position=2 should be erased in event handling.

Attachments (1)

example_delay.log (1.7 MB ) - added by ni.ding@… 6 years ago.
log file

Download all attachments as: .zip

Change History (3)

by ni.ding@…, 6 years ago

Attachment: example_delay.log added

log file

comment:1 by anonymous, 6 years ago

Resolution: fixed
Status: newclosed

comment:2 by ni.ding@…, 6 years ago

I close this ticket since the behavior of the delay operator is correct. The interpolation time value 1.000000e-005 is before 3.00001e-005 the event time. The interpolation is between 0 and 0.

Note: See TracTickets for help on using tickets.