Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#1972 closed defect (fixed)

Reinit in when equations with condition initial() should report an error

Reported by: Adrian Pop Owned by: Adrian Pop
Priority: high Milestone: 1.9.0
Component: Frontend Version: trunk
Keywords: Cc: Lennart Ochel, Jens Frenkel, Willi Braun

Description

From Lennart (lochel) comment on bug #1688:
reinit used in a when initial() clause:

when initial() then
  reinit(x, u);
end when;

That makes no sense and is not valid.
Perhaps, that should be caught in the Frontend?

Change History (6)

comment:1 by Adrian Pop, 12 years ago

The question is if this really makes no sense.

Say you load "u" from a file table in an initial
equation or algorithm and then in when initial()
you set "x" to it.

comment:2 by anonymous, 12 years ago

in such y case you can with:

when initial() then
  x = u;
end when;

The problem is that initial() does not generate an event.

Last edited 12 years ago by Adrian Pop (previous) (diff)

comment:3 by Adrian Pop, 12 years ago

Ok. I'll already started to add the check. I'll continue.

comment:4 by Adrian Pop, 12 years ago

Resolution: fixed
Status: newclosed

Fixed in r14246 and r14247 and r14250 ...
Lots or revisions to get it right :)

comment:5 by Adrian Pop, 12 years ago

Incredible how many occurrences of this when initial() then reinit we had in the testsuite :)
The same model several times with some differences.

comment:6 by Lennart Ochel, 12 years ago

Here goes something wrong. It is not possible to replace or even convert a reinit into an assignment. If that were possible, there were no reinit at all.
If you would like to assign some value to a state, use an initial equation/algorithm or binding. In facts, when initial() is not the same as an initial equation/algorithm.
However, good to see that we can already caught these fals statements in the frontend.

Note: See TracTickets for help on using tickets.