Can a callback be triggered at the initial time point (at t=0)

I am using the code from advanced_simulations - (the one using CallbackSets) and just modified the time to include t=0.0.

ps_cb_1 = PresetTimeCallback([3.0, 7.0], integ -> integ[:X1] += 5.0)

and added a time zero

ps_cb_1 = PresetTimeCallback([0.0, 3.0, 7.0], integ -> integ[:X1] += 5.0)

but it does not get triggered at t=0, however adding t=1e-14 works fine.

ps_cb_1 = PresetTimeCallback([1e-14, 3.0, 7.0], integ -> integ[:X1] += 5.0)

Is this the expected behavior ?

I guess at the first time step of the integrator t>0 therefore it would miss t=0.

If so is there an elegant way to trigger the callback at t=0. Of course one can modify the defaults but it is not very pretty.

Many thanks for your input.

I think it might work if you set ps_cb_1 = PresetTimeCallback([0.0, 3.0, 7.0], integ -> integ[:X1] += 5.0, filter_tstops=false)

Thanks for the input - made me look for the docs on PresetTimeCallback.

Unfortunately the callback still does not get triggered at t-0.

From the docs the flag controls whether to filter out tstops beyond the end
of the integration timespan and what I need in the very beginning.

Resurrecting this thread for posterity:

I prodded around and found that setting the initialize keyword to a no-op similar to this:

PresetTimeCallback([0., 3.], integ-> integ[:X1] += 5., initialize=(_cb, _u, _p, _t) -> nothing)

makes the solver do the modification at the initial time. You have to make sure to handle save_positions with care. I had it set to (true,true) and then got two tstops at the initial time, so that the very first u value still does not have the callback effect, but the next u value, still at the initial time, has it.