JuliaDynamics / DynamicalSystemsBase.jl

Definition of dynamical systems and integrators for DynamicalSystems.jl
Other
56 stars 29 forks source link

CoupledDDEs #220

Open awage opened 3 weeks ago

awage commented 3 weeks ago

I saw the fantastic work on CoupledSDEs. What about other specialized solvers? In particular DDEs or of interest in the dynamical system community.

At first sight a wrapper around DDEProblem should be doable.

Any thoughts based on your experience integrating SDEs?

Datseris commented 3 weeks ago

If you look at #212 it was quite a bit of work and back and forth. I think the whole process took a couple of months on and off... :D @oameye was the main driver so he can write about how hard it was.

For me what was mindblowing was that Attractors.jl worked out of the box for a multistable SDE FitzHugh Nagumo. We didn't have to change anything there !

With DDEs we have a problem to solve: what would be dimension(ds)? As DDEs are effectively infinitely dimensional. What would be current_state(ds)? What sorts of additional quierying function you would need? Would the delay time be part of the parameters or something special like the σ of the SDEs?

I know nearly nothing about how numerically solving a DDE works unless you do it in discretized time. And I'd guess some knowledge on that front would be important to know how to handle this object as a dynamical system.

But in principle, as long as this implements the DynamicalSystem api, that's all we need.

awage commented 2 weeks ago

I had a first try at defining CoupledDDES and it works for the examples I tried.

function duffing_delay!(du, u, h, p, t)
    α = p[1]; F = p[2]; ω = p[3]; tau = p[4]
    hist = h(p, t - tau)[1]
    du[1] = -u[1]*((1+α)*u[1]^2 -1) + α*hist + F*sin(ω*t)
end
α = -0.925; F = 0.525; ω = 1.; tau = 1.065; x = 1.; y = 1.;   
lags = [tau]; 
h(p,t) =  [x,y]
u0 = [x, y]
ds = CoupledDDEs(duffing_delay!, u0, [α, F, ω, tau]; h = h, constant_lags = lags)
y,t = trajectory(ds, 1000)

It just works!

Now, before beginning the PR process I have to design tests. But it will be very similar to the architecture of CoupledSDE It may take a while.

Datseris commented 2 weeks ago

With DDEs we have a problem to solve: what would be dimension(ds)? As DDEs are effectively infinitely dimensional. What would be current_state(ds)? What sorts of additional quierying function you would need? Would the delay time be part of the parameters or something special like the σ of the SDEs?

Before tests you need to figure out the above, as they are conceptual issues, not technical.

Datseris commented 2 weeks ago

But it is of course fantastic that things work straightforwardly :) yet another testament of how nice is the DynamicalSystem interface. Which makes sense as it has been through 4 reworks... :P

awage commented 2 weeks ago

I literally copied the file continuous_time_sde.jl and replaced SDE for DDE everywhere. Some small changes here and there and it worked.

For your specific questions: