@@ -8,50 +8,45 @@ function DynamicalSystems.interactive_poincaresos(ds, plane, idxs, complete;
88 # Makie kwargs:
99 color = randomcolor,
1010 scatterkwargs = (),
11- labels = (" u₁" , " u₂" ),
12- # DiffEq kwargs:
13- diffeq = NamedTuple ()
11+ labels = (" u₁" , " u₂" )
1412 )
1513
16- error (" this function has not yet been updated to DynamicalSystems.jl v3.0. PR welcomed!" )
17- # TODO : What is needed here is to make this use `PoincareMap`.
18- # and that's it!
19-
14+ # Basic sanity checks on the method arguments
2015 @assert typeof (plane) <: Tuple
2116 @assert length (idxs) == 2
2217 @assert eltype (idxs) == Int
2318 @assert plane[1 ] ∉ idxs
2419 u0 = DynamicalSystems. get_state (ds)
2520
26- # This is the low-level call of poincaresos:
27- DynamicalSystems. DynamicalSystemsBase. check_hyperplane_match (plane, DynamicalSystems. dimension (ds))
28- integ = DynamicalSystems. integrator (ds, u0; diffeq)
29- planecrossing = ChaosTools. PlaneCrossing (plane, direction > 0 )
3021 i = DynamicalSystems. SVector {2, Int} (idxs)
3122
32- figure = Figure (resolution = (1000 , 800 ), backgroundcolor = DEFAULT_BG )
23+ figure = Figure (size = (1000 , 800 ), backgroundcolor = :white )
3324
3425 T_slider, m_slider = _add_psos_controls! (figure, tfinal)
3526 ax = figure[0 , :] = Axis (figure)
3627
37- # Initial Section
38- f = (t) -> planecrossing (integ (t))
39- data = ChaosTools. _poincaresos (integ, f, planecrossing, T_slider[], i, rootkw)
28+ # Construct a new `PoincareMap` structure with the given parameters
29+ pmap = DynamicalSystems. DynamicalSystemsBase. PoincareMap (ds, plane;
30+ direction, u0, rootkw, Tmax = tfinal[2 ])
31+
32+ # Compute the initial section
33+ psos, = trajectory (pmap, T_slider[]; t0 = 0 )
34+ data = psos[:, i]
4035 length (data) == 0 && error (ChaosTools. PSOS_ERROR)
4136
4237 positions_node = Observable (data)
4338 colors = (c = color (u0); [c for i in 1 : length (data)])
4439 colors_node = Observable (colors)
4540 scatter! (
4641 ax, positions_node, color = colors_node,
47- markersize = lift (o -> o* px, m_slider), marker = MARKER , scatterkwargs...
42+ markersize = lift (o -> o* px, m_slider), marker = :circle , scatterkwargs...
4843 )
4944
5045 ax. xlabel, ax. ylabel = labels
5146 laststate = Observable (u0)
5247
5348 # Interactive clicking on the psos:
54- MakieLayout . deactivate_interaction! (ax, :rectanglezoom )
49+ Makie . deactivate_interaction! (ax, :rectanglezoom )
5550 spoint = select_point (ax. scene)
5651 on (spoint) do pos
5752 x, y = pos; z = plane[2 ] # third variable comes from plane
@@ -62,13 +57,13 @@ function DynamicalSystems.interactive_poincaresos(ds, plane, idxs, complete;
6257 return
6358 end
6459
65- DynamicalSystems . reinit! (integ, newstate)
66- data = ChaosTools . _poincaresos (integ, f, planecrossing, T_slider[] , i, rootkw)
60+ psos, = trajectory (pmap, T_slider[], newstate; t0 = 0 )
61+ data = psos[: , i]
6762 positions = positions_node[]; colors = colors_node[]
6863 append! (positions, data)
6964 c = color (newstate)
7065 append! (colors, fill (c, length (data)))
71- # update all the observables with Array as value:
66+ # Update all the observables with Array as value:
7267 positions_node[], colors_node[], laststate[] = positions, colors, newstate
7368 end
7469 display (figure)
0 commit comments