Bug introduced after 10.0, in or before 10.3, persisting through 13.2.1
The exact problem I am dealing with has already been asked and answered here.
Unfortunately the solution no longer seems to work. In fact when I run the solution
equation = x'[t] + (x[t] - λ[t]) == 0;
sol = NDSolveValue[{equation, x[0] == 0, λ[0] == 1,
WhenEvent[x'[t] == 0.25, λ[t] -> x[t]]},
x, {t, 0, 5}, DiscreteVariables -> {λ}]
I get nothing back. There is no error indication. Mathematica simply stops after a single integration step and returns nothing. I have already checked that the solution works fine if I simply replace in the condition inside WhenEvent with x[t] == 0.25 instead of the first derivative.
My speculation is that at some point someone decided to remove the possibility of using a WhenEvent with a condition that depends on a discrete variable when the action affects the discrete variable itself. Is there some workaround to this? It is unavoidable that my condition must have x'[t] in it.
NDSolvedoesn't parallelize, either. What's parallelized is the basic arithmetic operation when the system is large. See discussion in https://mathematica.stackexchange.com/q/208784/1871 Also, generally theExplicitRungeKuttamethod isn't that efficient according to my (limited) experience, but who knows. For large system, compilation is often a good choice, but that's relatively advanced topic, see e.g. https://mathematica.stackexchange.com/q/208762/1871 – xzczd Feb 28 '23 at 08:42