jckantor / TCLab

Software support for the Temperature Control Laboratory.
Apache License 2.0
13 stars 22 forks source link

Add a flag for clock which is guaranteed not to error #99

Closed alchemyst closed 5 years ago

alchemyst commented 6 years ago

One of the most frequent complaints I'm getting from students is that clock loses sync and then raises an error during long runs. For instance, they may want to schedule several long runs overnight, but clock loses sync 20 minutes into the run. This can be very frustrating, especially if the overrun is not very large.

I suggest a flag which allows for overruns and returns the difference in time steps between this and the next time step so that users can handle this correctly in their code, something like:

for dt, t in clock(1000, overrun=True):
    # use dt to for instance do integration calculations correctly.
jckantor commented 5 years ago

So I've set the default tol to float('inf') which never error. The returned t is now set to 2 digits, so users can compute dt to the 100th second.