[Discussion] Event iteratioin, definition and its handling in tools 
[Discussion] Event iteratioin, definition and its handling in tools 
liuliu 
Jan 6 2012, 10:32 AM
Post
#1

Member Group: Administrators Posts: 24 Joined: 21November 06 Member No.: 115 
Hello everyone,
I get somehow confused with the event iteration and the pre() operator. Definition from ModelicaSpecification3.2: EventIteration: "A new event is triggered if at least for one variable v “pre(v) <> v” after the active model equations are evaluated at an event instant. In this case the model is at once reevaluated. This evaluation sequence is called “event iteration”." pre(): "Returns the “left limit” y(tpre) of variable y(t) at a time instant t. At an event instant, y(tpre) is the value of y after the last event iteration at time instant t (see comment below). The pre() operator can be applied if the following three conditions are fulfilled simultaneously: (1) variable y is either a subtype of a simple type or is a record component, (2) y is a discretetime expression (3) the operator is not applied in a function class." Similar definitions are to be found in "Principles of objectoriented modeling and simulation with modelica 2.1 by Peter Fritzson"[1] Take a close look into the book [1] there is an example called "MultipleEvents" at page 427. Since this model is not supported by all the tools, i will modify into the following one. CODE model MultipleEvents discrete Integer x(start=1); discrete Integer y(start=0); equation when x==2 then //Event A y=pre(x)+1; end when; when time>=2 then //Event B x=2; end when; end MultipleEvents; also simple example , isn't it? So far so good. Now the problem: The events A and B are multiple events at the same time instant, Event B triggers Event A thus the order of events is B>A, Question is: The value of pre(x) after B is 2 or 1? or the value of y is 3 or 2 after both events? The book [1] says: pre(x)= 2 and y=3, however, simulate the model in dymola and opemmodelica will give the value pre(x)=1 and y=2. The problem is in my opinion an interpretation problem. What is event iteration and what is event evaluation. Accroding to the definition in the modelica specification, the sequnce of evaluations is called event iteration. That is to say, the pre() value is only updated after the whole procedure of event iteration (in our example after B and A), but not after B and before A. If this is the case, we always have to write "when pre()" to enforce every evaluation to be a single iteration. Is that the correct interpretation? If some one has a better idea to understand this problem, please teach me. 
LoFi Version  Time is now: 20th June 2019  01:40 PM 