#5188 closed discussion (invalid)
When not triggering in initialization
| Reported by: | Owned by: | Lennart Ochel | |
|---|---|---|---|
| Priority: | normal | Milestone: | Future |
| Component: | Initialization | Version: | v1.13.0-dev-nightly |
| Keywords: | when, if edge, initial equation | Cc: |
Description
Is the following behavior for when equations while initializing desired? When simulating the following model a stays 1, so the when equation is not evaluated.
model initial_when
Real x(start=1), dx;
discrete Real a(start=1);
Boolean y(start=false);
Boolean z(start=false);
Boolean h1(start=false, fixed=true), h2;
equation
der(x) = dx;
dx = a*x;
h1 = x>=0;
h2 = dx>=2;
when h1 then // equivalent to "if edge(h1) then" // equivalent to "if h1 and not pre(h1) then"
y = true;
end when;
when y then
a = 2.0;
end when;
when h2 then
z = true;
end when;
end initial_when;
If
when h1 then y = true; end when;
is replaced with
if edge(h1) then
y = true;
else
y = pre(y);
end if;
y is set to true as expected. Of course a is still wrong.
Dymola is returning the same result as OpenModelica in both cases.
Change History (1)
comment:1 by , 7 years ago
| Resolution: | → invalid |
|---|---|
| Status: | new → closed |
Version 0, edited 7 years ago by (next)
Note:
See TracTickets
for help on using tickets.

From the Modelica Specification, Section 8.6
So, as far as I understand, the behaviour of both tools is correct.
If you replace
whenwithif, then it's a different story, as the above-stated rule no longer applies.