PresetTimeCallback with array in affect function

Marco_Masi
Sun, 24 Aug 2025 11:45:44 +0000
General Usage

I’m trying to understand how to use the PresetTimeCallback(tstops,affect!) where tstops is an array of time steps and the affect function should also affect the integration each time with different values.
For example, for one time and one affect I used:

DE.PresetTimeCallback(t1, integrator -> integrator.p[1] += v1)

This works.
For a list of timesteps

DE.PresetTimeCallback([t1, t2, t3], integrator -> integrator.p[1] += v1);

works as well. It just applies the same v1.
However, I would like it to apply at each different time t1, t2, t3, … the values v1, v2, v3… I tried something sort of…

DE.PresetTimeCallback([t1, t2, t3], integrator -> integrator.p[1] += [v1, v2, v3]);

but that doesn’t work.
Any suggestion how to do that?

2 posts - 2 participants