Event management in the Modelica hybrid model

I am confused by the hybrid modeling paradigm in Modelica. On the one hand, events are useful; on the other hand, they should be avoided. Let me explain my case:

I have a large model consisting of several buildings in the neighborhood that has been simulated for over 1 year. Initially, the model worked very slowly. Adding noEvent () around as many if-conditions as possible greatly accelerated the speed.

As the development continued, the control over the model became more difficult, and again I have a lot of events, sometimes with very short intervals. To give an idea:

Number of (model) time events : 28170 Number of (U) time events : 0 Number of state events : 22572 Number of step events : 0 

These events blew up the output (for proper post-processing I need variables on the events) and slows down the simulation. And what's more, I feel that some of noEvent (if ...) are leading to unexpected behavior.

I wonder if this decision will force my events at certain time steps and forbid them between these time steps? Ideally, I would like to trigger these “forced events” based on certain conditions. For example: during the day they should be every 15 minutes, with high solar radiation every minute, during the nights I don’t want events at all.

Is that a good idea? I think it will be faster, since many events in the state will become events of the time? How can this be done with Modelica 3.2 (in Dymola)?

Thanks for all the answers. Rule

+4
source share
1 answer

A few comments.

Firstly, if you have a simulation with a large number of events (relative to the total duration of the simulation), the first thing I would like to advise you is to use a lower order integrator. The point here is that higher order integrators usually allow you to take longer steps. But if these steps are constantly truncated by events, they simply become very expensive.

Secondly, you can try integrators with fixed steps. Depending on the tool, they can implement this kind of “event pool and simultaneously run them all” in the context of fixed-time stage integrators. But the specification says nothing about how tools should deal with events that occur between fixed time steps.

Thirdly, another way to approach this would be to “unify” your events on your own. The easiest way I could do this is to accept all the statements that are currently generating events and wrap them in a "when sample (..., ...) then" statement. This way you can make sure that events were triggered only at certain intervals. This would be more portable than a fixed time step approach. I think this is what you actually suggested in your question, but it’s important to point out that it should not be based on time steps (the model has no idea about the time step), but rather on a given model sampling interval (which will be, in practice, completely independent of time steps).

As you note, using "sample (..., ...)" will turn them into temporary events, and, yes, it should be faster.

+5
source

Source: https://habr.com/ru/post/1446182/


All Articles