neurophysik / jitcdde

Just-in-time compilation for delay differential equations
Other
56 stars 14 forks source link

Example State-dependent delays? #7

Closed mmbosschaert closed 6 years ago

mmbosschaert commented 7 years ago

It is stated that state-dependent delays should work. Is there a minimal example provided?

Wrzlprmft commented 7 years ago

No, there is no minimal example. So far, there was no demand for this and I haven’t looked into simple, well-posed examples. If you are aware of one, I will happily implement it.

However, usage is straightforward. Instead of y(0,t-tau) you just use for instance y(0,t-tau*y(1)).

Please keep in mind that the time-dependence of your delay should only change slowly. I haven’t intensively tested this, so if you encounter any issues, feel free to tell me.

mmbosschaert commented 7 years ago

The example I would like to implement is given by y’(t)=-y(t-2-y(t)^2)+5 with initial condition given by 9/2 for t<-1 and -1/2 for -1<=t<=0

mmbosschaert commented 7 years ago

Maybe I'm doing something wrong? t=0 gives y'(0)=-y(0-2-y(0)^2)+5=-y(-2-(-1/2)^2)+5=-9/2+10/2=1/2

Wrzlprmft commented 7 years ago

Okay, here is an implementation of your problem.

As you will notice, there is a problem with the discontinuity in the past (at t=−1): For 0<t<2, If the delay term points to t>−1, the dynamics will change such that it points to an earlier time, otherwise the direction is the opposite. This means that the target of the delay will be “attracted” to t=−1 (yes, we have a dynamical system within a dynamical system). Now, with a discontinuity at t=−1, this is obviously a problem, as the behaviour of the DDE is not properly defined.

However, JiTCDDE doesn’t allow for implementing discontinuities in the first place – they can only be approximated by a sigmoid (whose steepness can be controlled by eps in the example code). As you can see, y(t) ≈ sqrt(t-1) for 1<t<2, which means a constant delay target within the sigmoid.

Finally, for t>2, there is no value within the sigmoid to sustain the dynamics anymore and the delay target will sink to lower values again.

Note that for all of this it is not necessary to have a DDE, as the delay target never exceeds t=0 and thus always dwells in the realm of the initial conditions. Thus the dynamics is equivalent to that for the ODE ẏ=½−5·Θ(t−1−y²), where Θ is the Heaviside function.

Wrzlprmft commented 7 years ago

By the way: What is the motivation/source of this problem?

mmbosschaert commented 7 years ago

The example is from the book Introduction to the Theory and Application of Differential Equations with Deviating Arguments by S. B. Norkin L. E. El'sgol'ts