From b1e88b28d768c4f21c771835ad87132ea2263fac Mon Sep 17 00:00:00 2001 From: awage <> Date: Sun, 1 Sep 2024 13:19:46 +0200 Subject: [PATCH] add example for documentation --- src/boundaries/example_stagger.jl | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 src/boundaries/example_stagger.jl diff --git a/src/boundaries/example_stagger.jl b/src/boundaries/example_stagger.jl new file mode 100644 index 00000000..e360a22d --- /dev/null +++ b/src/boundaries/example_stagger.jl @@ -0,0 +1,30 @@ +using Attractors +using CairoMakie + +# Coupled Hénon maps +function F!(du, u ,p, n) + x,y,u,v = u + A = 3; B = 0.3; C = 5.; D = 0.3; k = 0.4; + du[1] = A - x^2 + B*y + k*(x-u) + du[2] = x + du[3] = C - u^2 + D*v + k*(u-x) + du[4] = u + return +end + +# The region should not contain any attractors. +R_min = [-4; -4.; -4.; -4.] +R_max = [4.; 4.; 4.; 4.] + + +# Initial box and initial condition. +sampler, isinside = statespace_sampler(HRectangle(R_min,R_max)) +x0 = sampler() +df = DeterministicIteratedMap(F!, x0) +xi = stagger_trajectory!(df, x0, 30, isinside; δ₀= 2.) +@show Tp = Attractors.escape_time!(df, xi, isinside) + +v = stagger_and_step!(df, x0, 10000, isinside; stagger_mode = :adaptive, δ = 1e-4, Tm = 10, max_steps = Int(1e5), δ₀ = 2.) +v = hcat(v...)' +scatter(v[:,1], v[:,3]; markersize = 3) +