Opened 8 years ago

Last modified 7 years ago

#4301 accepted enhancement

Feature to break the simulation when the steady state has been reached

Reported by: Adrian Pop Owned by: Lennart Ochel
Priority: high Milestone: Future
Component: Backend Version:
Keywords: Cc:

Description (last modified by Adrian Pop)

Proposed here:
http://stackoverflow.com/questions/42673420/global-measure-to-test-when-steady-state-of-system-is-reached

The first point sounds like a good to have feature and doesn't seem that hard to implement, basically a terminate when all the ders are 0 (within an epsilon) for a number of steps.

For the second point we would need a global operator (that returns true when all ders are within an epsilon interval) that one can use in equations to enable / disable parts of the system.

Attachments (2)

RL.mo (2.0 KB ) - added by anonymous 8 years ago.
RL2.mo (2.0 KB ) - added by anonymous 8 years ago.

Download all attachments as: .zip

Change History (18)

comment:1 by Lennart Ochel, 8 years ago

Owner: changed from somebody to Lennart Ochel
Status: newaccepted

I can take care of the first point.

comment:2 by Adrian Pop, 8 years ago

For the second point we could propose an extension of the Modelica Specification with an operator called steadyState(epsilon) which would return true if each of the ders are < epsilon.

The only issues to think about is what to return during initialization when the ders are zero, etc. I guess we can safely return false for any other phase than simulation.

Last edited 8 years ago by Adrian Pop (previous) (diff)

comment:3 by Adrian Pop, 8 years ago

Description: modified (diff)

comment:4 by Adrian Pop, 8 years ago

Description: modified (diff)

comment:5 by Adrian Pop, 8 years ago

Component: *unknown*Backend

This is back-end for the first point and front-end and back-end for the second point.

comment:6 by Lennart Ochel, 8 years ago

See OMCompiler#1531 for the first point.

comment:7 by anonymous, 8 years ago

Somehow this feature is invalidated by sources adding perturbations after derivatives are all zero.
Should this feature check also sources?

in reply to:  7 ; comment:8 by Lennart Ochel, 8 years ago

Replying to anonymous:

Should this feature check also sources?

I don't think that this is possible (or necessary). Anyway, can you provide an example to emphasise your point?

in reply to:  8 comment:9 by Adrian Pop, 8 years ago

Replying to lochel:

Replying to anonymous:

Should this feature check also sources?

I don't think that this is possible (or necessary). Anyway, can you provide an example to emphasise your point?

It is possible I guess if you have time events and the event comes after the steady state has been reached. Maybe we could check if there is a time event in the queue and give a warning about it when terminating the simulation.

in reply to:  8 ; comment:10 by anonymous, 8 years ago

Replying to lochel:

Replying to anonymous:

Should this feature check also sources?

I don't think that this is possible (or necessary). Anyway, can you provide an example to emphasise your point?

Consider RL.mo: everything is constant between 4.5 and 5s; But starting from t=5s current starts to change again.
In this case there is a time event in the queue (inside step block)

by anonymous, 8 years ago

Attachment: RL.mo added

comment:11 by Christoph Buchner <buchner@…>, 8 years ago

When detecting the steady state, do you not also have to make sure that all derivatives *stay* below the threshold? Otherwise, if you have a simple oscillation, would the simple logic not interrupt the simulation as soon as the first maximum of the only state is reached (as there the der is 0)?

in reply to:  11 ; comment:12 by Lennart Ochel, 8 years ago

Replying to Christoph Buchner <buchner@…>:

When detecting the steady state, do you not also have to make sure that all derivatives *stay* below the threshold? Otherwise, if you have a simple oscillation, would the simple logic not interrupt the simulation as soon as the first maximum of the only state is reached (as there the der is 0)?

This is a good point. So I could introduce a (user defined) time interval in which all derivatives have to be zero. Would that be a good idea?

in reply to:  10 comment:13 by Lennart Ochel, 8 years ago

Replying to anonymous:

Replying to lochel:

Replying to anonymous:

Should this feature check also sources?

I don't think that this is possible (or necessary). Anyway, can you provide an example to emphasise your point?

Consider RL.mo: everything is constant between 4.5 and 5s; But starting from t=5s current starts to change again.
In this case there is a time event in the queue (inside step block)

I see. However, I'm not sure if we should include a check for time events, because it is not possible to do the same for state events, which would make things confusing.

comment:14 by anonymous, 8 years ago

Furthermore, it is possible to create systems in which the simulation suddenly "fires-up", without events.
An example (a bit tricky, indeed) is in RL2.mo.

by anonymous, 8 years ago

Attachment: RL2.mo added

in reply to:  12 comment:15 by anonymous, 8 years ago

AFAIK it is impossible to have oscillations system with a single state and non-oscillating source.
So if all derivatives are zero, they will stay as such, except for cases in which the sources change their values.

Replying to lochel:

Replying to Christoph Buchner <buchner@…>:

When detecting the steady state, do you not also have to make sure that all derivatives *stay* below the threshold? Otherwise, if you have a simple oscillation, would the simple logic not interrupt the simulation as soon as the first maximum of the only state is reached (as there the der is 0)?

This is a good point. So I could introduce a (user defined) time interval in which all derivatives have to be zero. Would that be a good idea?

comment:16 by Martin Sjölund, 7 years ago

The testcase added for this is not working: 9bca22796

Note: See TracTickets for help on using tickets.