Ticket #103 (closed enhancement: fixed)
Specification of reinit (was: Two reinits in Translational.Stop)
| Reported by: | otter | Owned by: | HansOlsson |
|---|---|---|---|
| Priority: | normal | Milestone: | ModelicaSpec3.1 |
| Component: | --Modelica Specification-- | Version: | Spec3.0 |
| Severity: | normal | Keywords: | |
| Cc: | Hide ticket: | no |
Description
Modelica.Mechanics.Translational.Stop has the following code fragment:
when not (s < smax - L/2) then reinit(s, smax - L/2); if (not initial() or v>0) then reinit(v, 0); end if; end when; when not (s > smin + L/2) then reinit(s, smin + L/2); if (not initial() or v<0) then reinit(v, 0); end if; end when;
This is not correct Modelica according to Modelica 3.0, page 24:
reinit(x,expr): In the body of a when clause, reinitializes x with expr at an event instant. x is a Real variable (resp. an array of Real variables, in which case vectorization applies according to Section 12.4.5) that must be selected as a state (resp., states) at least when the enclosing when clause becomes active. expr needs to be type-compatible with x. The reinit operator can only be applied once for the same variable (resp. array of variables). It can only be applied in the body of a when clause. See also Section 8.3.6 .
The model should be corrected to follow the specification (so, to have only one reinit(..) call). It might be possible and useful to extend Modelica so that the reinit(..) operator can be applied to the same variable several times, in the same algorithm section, but this requires an enhancement of the Modelica language.
