Open KeAWang opened 1 year ago
Hi, I think what you are trying to do here is not really well-defined. A delta distribution is not something you'll be able to handle directly in any numerical code. Of course, you can do the standard engineering trick and integrate the differential equation in an epsilon environment around the jump $t0$ which gives $$\int{t_0 - \epsilon}^{t_0 + \epsilon} \dot y dt = y(t_0 + \epsilon) - y(t0 - \epsilon) = - \int{t_0 - \epsilon}^{t0 + \epsilon} y dt + 100 \int{t_0 - \epsilon}^{t_0 + \epsilon} \delta(t - t_0) dt \xrightarrow{\epsilon \rightarrow 0} 100 $$ and tells you that $y$ will jump by 100 after passing $t_0$. So what you could do is to integrate the differential equation without the delta distribution numerically until $t_0$ and then continue the integration from $t_0$ onwards with the initial condition given by whatever the first integration produced + 100.
As @jaschau suggests, probably the simplest approach is to just split your problem into two separate diffeqsolve
s. (Actually a lax.scan
over diffeqsolve
s would be slightly better, as that'll reduce compilation time.) And then apply your desired impulse between the two solves. It's expected that using step_ts
wouldn't result in the delta function being noticed, I'm afraid -- what you're trying to do isn't within the normal remit of differential equation solvers.
Other notes:
[Also, wait, we can use LaTeX on GitHub now? Hurrah!]
That makes sense! Thank you to both of you :) Would be great for diffrax to have non-terminating event handling, especially for the simple case where the timestamps are known. Unfortunately won't be able to code up the feature now but maybe in the future!
I'm trying to integrate a jump discontinuous ODE using an adaptive solver (i.e. discontinuous at a specific timepoint).
However, the integration seems to ignore my
step_ts
:Output:
I'm avoiding
jump_ts
based on https://github.com/patrick-kidger/diffrax/issues/58, which addressed the case where you have piecewise constant vector fields. However I'm not quite sure what to do when there's a delta-function in the vector field (impulse external control)Is there a way to do this in diffrax?