Opened 16 years ago
Closed 10 years ago
#1048 closed defect (fixed)
delay gives wrong result for discrete signals (from MathCore)
Reported by: | krsta | Owned by: | Willi Braun |
---|---|---|---|
Priority: | critical | Milestone: | 1.9.1 |
Component: | Run-time | Version: | |
Keywords: | Cc: | krsta, Willi Braun |
Description
When using delay on discrete signals, the delay-signal is no longer discrete, the interpolation does not take events into consideration.
Test example:
model delaytest Integer n; Integer n2; Integer n3; parameter Real delayMax=10; equation when sample(0,0.1) then n = pre(n) + 1; end when; n2 = integer(delay(n,0.34)); n3 = integer(delay(n,1.0/(n2+0.01),delayMax)); end delaytest;
Note that n2 and n3 does not have discrete jumps as n does.
Please add this example to the testsuite once it is working.
Implementation note: I guess that in order to get this to work, the delay function must identlify when an event occurs and force an extra emit to occur.
Change History (5)
comment:1 by , 15 years ago
comment:2 by , 11 years ago
Cc: | added |
---|---|
Component: | → Run-time |
Milestone: | → 1.9.0 |
Owner: | changed from | to
Status: | new → assigned |
Lennart: Is the following the correct result?
loadString("model M Integer n; Integer n2; Integer n3; parameter Real delayMax=10; equation when sample(0,0.1) then n = pre(n) + 1; end when; n2 = integer(delay(n,0.34)); n3 = integer(delay(n,1.0/(n2+0.01),delayMax)); end M;");getErrorString(); simulate(M);getErrorString(); plot({n,n2,n3});getErrorString();
comment:4 by , 11 years ago
Owner: | changed from | to
---|
I get the following message:
Simulation execution failed for model: M assert | debug | Negative delay requested -4.65661e-010
There is something wrong with the delay handling.
comment:5 by , 10 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
The result looks fine compared to dymola, so it seems that this is fixed in the meanwhile.
http://intranet/trac/mathmodelica/ticket/1549
There are a couple of issues that complicates things:
Note: This does not work in Dymola 6, but it does in Dymola 7.
Delays where the result is stored in an integer seems to be completely broken so the test example above does not work. However, if we change n2,n3 to Real instead it works.
The the missing feature is that we don't generate delayed events so n2 and n3 doesn't make discrete changes as they should.