Making a callback event at a single timepoint

Simple question. At a certain timepoint (e.g. t = 100) I want to make a callback, changing a parameter or variable value.
The most intuitive way would be

function condition(u,t,integrator)
    t == 100
end

however the solver seems to miss it (not strange if it just takes timesteps). One could ofcourse workaround that, e.g. add a extra variable to u with an initial value 1.

function condition(u,t,integrator)
    t > 100 && u[end] == 1
end

Then you add a line to the integrator setting u[end] = 0.

This however feels unnecessarily complicated. I do not know, but is there a simpler way to do this. I cannot imagine that it is a very uncommon thing that I am trying to do.

Pass in tstops = [100] to make the solver stop there, allowing the condition to go off at exactly that time point.

(Note that this example was one of the ones in the video tutorial, so you may find this helpful)

http://nbviewer.jupyter.org/github/JuliaDiffEq/DiffEqTutorials.jl/blob/master/Introduction/CallbacksAndEvents.ipynb

I want to make a TimedCallback though that does that automatically since this seems to be a pretty common question.

You can use tstops to ensure that the integrator will stop at exactly t = 100. See http://docs.juliadiffeq.org/stable/features/diffeq_arrays.html#Example:-A-Control-Problem-1. You can also add a stop time dynamically while simulating using add_tstop!(integrator,new_t).

And I thought I was going to beat you.

Thank you guys. Yes I should probably watch that one properly, my mistake. Will do so when I get home.