2.6 Creating a Hybrid Model in the WSM Package …
85
Fig. 2.73 Graph of the position of the bouncing ball above the floor
Fig. 2.74 Bouncing ball speed change
One way to avoid unnecessary iterations is to use the built-in noEvent operator,
indicating to the solver that the generation of an event is not required. This operator
can be used only if the expression is continuous during the occurrence of the event
(it does not have to be differentiable).
model EventTest;
Real x1;
Real x2;
equation;
x1=if time < 3 then time else 3 ”Event generated at time=3”;
x2=noEvent (if time < 3 then time else 3) ”No event generated”;
end EventTest.
The noEvent operator can also be used to protect against incorrect calculations.
The following example calculates sin(x)/x. To eliminate division by zero, noEvent
is used to test the condition abs(x)>0 to make sure that sin(x)/x is not calculated at
x=0
Model GuardEval;
Real x;
Précédent

- 98/274

Suivant