Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register

noEvent

noEvent

Hi everybody,

I was wondering how the noEvent operator actually works and if it has any downsides using it.
I checked the Modelica Reference and Peter Fritzson's book. I do not really understand how it works.


ModelicaReference.Operators.'noEvent()'ModelicaReference.Operators.'noEvent()'
Turn off event triggering

Syntax
noEvent(expr)
Description
Real elementary relations within expr are taken literally, i.e., no state or time event is triggered.

smooth vs. noEvent
The noEvent operator implies that real elementary expressions are taken literally instead of generating crossing functions. The smooth operator should be used instead of noEvent, in order to avoid events for efficiency reasons. A tool is free to not generate events for expressions inside smooth. However, smooth does not guarantee that no events will be generated, and thus it can be necessary to use noEvent inside smooth. [Note that smooth does not guarantee a smooth output if any of the occurring variables change discontinuously.]

This explanation does not really help me understand how it is done.
How is it recognized that an expression stated within the noEvent operator becomes true?
And what are the downsides of using the noEvent operator.

Any help would be appreciated.

Thank you current/smile

Re: noEvent

Take a simple model like the following for example:

Code:

model M

  Real x = sin(5*time);
  Real y = if x >= 0 then x else -x;
end M;

It will cross from positive to negative at around time=0.6238. At this time, y may be negative despite that if-condition guarding against negative numbers. Why? Because the zero-crossing function is not exact and there will be a time event at a time that is not exactly when the condition triggers.

On the other hand, the following will generate a trajectory where y is always >= 0. But there is no event triggered at the time of the zero-crossing, so some other values might be affected if you actually need some calculation to update at this point.

Code:

model M

  Real x = sin(5*time);
  Real y = if noEvent(x >= 0) then x else -x;
end M;

There are 0 guests and 0 other users also viewing this topic