JuliaDynamics / ChaosTools.jl

Tools for the exploration of chaos and nonlinear dynamics
https://juliadynamics.github.io/DynamicalSystemsDocs.jl/chaostools/stable/
MIT License
188 stars 36 forks source link

Dynamical system "iterator" for returning back to a set in state space #319

Open PythagoreanCult opened 10 months ago

PythagoreanCult commented 10 months ago

We already have fuctionality for estimating return times.

We can simplify and re-use the codebase, by creating a new type of dynamical system, that is in discrete time, and it iterates a given dynamical system until it returns to a prescribed set with at least distance e or smaller. Here is some initial draft code:

struct ReturnDynamicalSystem
    ds::DynamicalSystem
    set::Something # the set to return to 
    mind::Real # must come at least `mind` close to set
    dt::Real
    maxt::Real # safety variable. if evolve for more than maxt without coming `mind` close, stop iteration
end

function step!(rds::ReturnDynamicalSystem)
    u = current_state(rds.ds)
    n = 0
    while distace(u, rds.set) > rds.mind
        step!(rds.ds)
        u = current_state(rds.ds)
        n += 1
        if n > rds.maxt 
            error("we didn't return in time")
        end
    end
    rds.dt = n
    return rds
end

rds = ReturnDynamicalSystem(ds, ...)

step!(rds) # evolve the internal ds until it comes `mind` close to the set
# and in the field `.dt` it would have recorded how much time this took 
u_close = current_state(rds)
n = rds.dt

step!(rds)