-
Notifications
You must be signed in to change notification settings - Fork 43
Description
There was some discussion about event iteration in #578, but I don't see that the current specification text makes the relation between reinit and event iteration clear. What we have is this:
\lstinline!reinit! does not break the single assignment rule, because \lstinline!reinit(x, expr)! in equations evaluates \lstinline!expr! to a value, then at the end of the current event iteration step it assigns this value to \lstinline!x! (this copying from values to reinitialized state(s) is done after all other evaluations of the model and before copying \lstinline!x! to \lstinline!pre(x)!).
and the criterion for convergence of the event iteration:
Before the start of the integration, it must be guaranteed that for all variables \lstinline!v!, \lstinline!v = pre(v)!.
However, this doesn't mention that the reinit essentially invalidates the "current event iteration step", meaning that the event iteration convergence test is not meaningful right away.
Here is a model which illustrates the need:
model ReinitLadder
Real x(start = 1, fixed = true);
equation
der(x) = -1;
when x < 0 then
reinit(x, 0.2);
elsewhen x > 0.1 then
reinit(x, 0.4);
elsewhen x > 0.3 then
reinit(x, 0.6);
elsewhen x > 0.5 then
reinit(x, 0.8);
elsewhen x > 0.7 then
reinit(x, 1.0);
end when;
annotation(
experiment(
StopTime = 3.0
)
);
end ReinitLadder;