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

valerdam
Thu, 16 May 2024 20:36:04 +0000
General Usage

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.

4 posts - 3 participants