@@ -8,50 +8,45 @@ function DynamicalSystems.interactive_poincaresos(ds, plane, idxs, complete;
8
8
# Makie kwargs:
9
9
color = randomcolor,
10
10
scatterkwargs = (),
11
- labels = (" u₁" , " u₂" ),
12
- # DiffEq kwargs:
13
- diffeq = NamedTuple ()
11
+ labels = (" u₁" , " u₂" )
14
12
)
15
13
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
20
15
@assert typeof (plane) <: Tuple
21
16
@assert length (idxs) == 2
22
17
@assert eltype (idxs) == Int
23
18
@assert plane[1 ] ∉ idxs
24
19
u0 = DynamicalSystems. get_state (ds)
25
20
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 )
30
21
i = DynamicalSystems. SVector {2, Int} (idxs)
31
22
32
- figure = Figure (resolution = (1000 , 800 ), backgroundcolor = DEFAULT_BG )
23
+ figure = Figure (size = (1000 , 800 ), backgroundcolor = :white )
33
24
34
25
T_slider, m_slider = _add_psos_controls! (figure, tfinal)
35
26
ax = figure[0 , :] = Axis (figure)
36
27
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]
40
35
length (data) == 0 && error (ChaosTools. PSOS_ERROR)
41
36
42
37
positions_node = Observable (data)
43
38
colors = (c = color (u0); [c for i in 1 : length (data)])
44
39
colors_node = Observable (colors)
45
40
scatter! (
46
41
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...
48
43
)
49
44
50
45
ax. xlabel, ax. ylabel = labels
51
46
laststate = Observable (u0)
52
47
53
48
# Interactive clicking on the psos:
54
- MakieLayout . deactivate_interaction! (ax, :rectanglezoom )
49
+ Makie . deactivate_interaction! (ax, :rectanglezoom )
55
50
spoint = select_point (ax. scene)
56
51
on (spoint) do pos
57
52
x, y = pos; z = plane[2 ] # third variable comes from plane
@@ -62,13 +57,13 @@ function DynamicalSystems.interactive_poincaresos(ds, plane, idxs, complete;
62
57
return
63
58
end
64
59
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]
67
62
positions = positions_node[]; colors = colors_node[]
68
63
append! (positions, data)
69
64
c = color (newstate)
70
65
append! (colors, fill (c, length (data)))
71
- # update all the observables with Array as value:
66
+ # Update all the observables with Array as value:
72
67
positions_node[], colors_node[], laststate[] = positions, colors, newstate
73
68
end
74
69
display (figure)
0 commit comments