Stopping simulation based on CPU time in Dymola/Modelica

Viewed 183

In Dymola, I'm able to do something like:

when time > 100 then
    assert(false,"Simulation taking too long");
end when;

to stop simulations based on the time variable itself.

However, what i'd like to do is stop the simulation based on elapsed CPU time. Dymola has a way to output the CPU time and it shows up in the results as CPUtime, but I don't know how to access the variable. In other words, this is what i'd like to do, but the CPUtime variable isn't in scope:

when CPUtime > 100 then
    assert(false,"Simulation taking too long");
end when;

Any suggestions, either how to access CPUtime, or other workarounds to kill simulations based on cpu time?

1 Answers

As already noted:

You can set this in Dymola 2022 in the simulation setup, or alternatively by setting Advanced.Simulation.MaxRunTime.

It's wall-clock time, which means that if you have a parallel simulation it will stop after 10s has passed and not when the cores together have spent 10s, and if you for some weird reason have a long sleep-call in the model it will still end.

(This was already noted in the comment - thanks Priyanka. However, stackoverflow for some reason warns that answers in comments may be lost.)

Related