Opened 18 years ago

Last modified 18 years ago

#101 closed defect (fixed)

Boolean events are not generated correctly (zero crossing problem?)

Reported by: Adrian Pop Owned by: Adrian Pop
Priority: critical Milestone:
Component: Version:
Keywords: Cc: Adrian Pop, haklu

Description


Change History (1)

comment:1 by Adrian Pop, 18 years ago

class Test_Timer
Boolean booleanStepy;
parameter Real booleanStepstartTime = 6 "Time instant of step start";
parameter Boolean booleanStepstartValue = false "Output before startTime";
Boolean timer_intu;
Real timer_inty;
Boolean timer_intu2(start = false);
discrete Real timer_intentryTime "Time instant when u became true";
Boolean fin_timer(start = false);
initial equation

pre(timer_intentryTime) = 0.0;

equation

booleanStepy =

if time >= booleanStepstartTime
then

not booleanStepstartValue

else

booleanStepstartValue;

when timer_intu then

timer_intu2 = true;
timer_intentryTime = time;

end when;
timer_inty =

if timer_intu and timer_int.u2
then

time - timer_intentryTime else 0.0;

booleanStepy = timer_intu;
fin_timer = timer_inty > 6.0;

end Test_Timer;

In this model the fin_timer is always 0 (zero), even if it should be true
when time is 12. However, if you change the equation:

fin_timer = timer_inty > 6.0;

with equation:

fin_timer = timer_inty - 6.0 > 0.0;

or with WRONG equation which should actually report an error:

fin_timer = noEvent(timer_inty > 6.0);

everything works perfectly.

Any idea why this happens?
I tried to reproduce this bug with simpler models, but I can't.
Seems is a problem with zero crossing that happens only in some
cases where there is a combination of when and ifs.

Regards,
Adrian Pop/

Note: See TracTickets for help on using tickets.