Hello @all,

Is there some semantic difference in these two models?

model dreieck
Real x(start = 1);
discrete Real x0(start = 1);
equation
der(x) = x0;
when sample(0,1) then
x0 = -pre(x0);
end when;
end dreieck;

model dreieck
Real x(start = 1);
discrete Real x0(start = 1);
equation
der(x) = x0;
algorithm // <-- inside algorithm section
when sample(0,1) then
x0 := -pre(x0);
end when;
end dreieck;

When I simulate them I get 2 different results (x plots vs time)
While in first model the slope (x0) changes from 1 to -1 at time 0
(due to the event from sample function at time 0)
the second model retains slope 1 for the first second. I don't exactly
understand why. In my opinion algorithm section must be executed
at time 0 too, thus changing x0 to -x0.
Can somebody explain please?

Regards, Daniel