Interactive Poincaré Surface of Section
Docstrings
#InteractiveChaos.interactive_poincaresos
— Function.
interactive_poincaresos(cds, plane, idxs, complete; kwargs...)
Open an interactive application for exploring a Poincaré surface of section (PSOS) of the continuous dynamical system cds
. Return an observable containing the latest initial state created by complete
, as well as its color.
The plane
can only be the Tuple
type accepted by poincaresos
, i.e. (i, r)
for the i
th variable crossing the value r
. idxs
gives the two indices of the variables to be displayed, since the PSOS plot is always a 2D scatterplot. I.e. idxs = (1, 2)
will plot the 1st versus 2nd variable of the PSOS. It follows that plane[1] ∉ idxs
must be true.
complete
is a three-argument function that completes the new initial state during interactive use, see below.
The function returns: an observable containing the latest initial state
and the scene
that is plotted. The scatter plot is scene.children[2]
.
Keyword Arguments
direction, rootkw
: Same use as inpoincaresos
.tfinal
: A 2-element tuple for the range of values for the total integration time (chosen interactively).Ttr
: A 2-element tuple for the range of values for the transient integration time (chosen interactively).markersizes = (-4, -1)
: A 2-element tuple for the range of the marker sizes (which scale exponentially: the actual size is10.0^markersize
).color
: A function of the system's initial condition, that returns a color to plot the new points with. A random color is chosen by default. Notice that for type stability reasons this function must return an instance ofRGBf0(red, green, blue)
.labels = ("u₁" , "u₂")
: Axis labels.diffeq...
: Any extra keyword arguments are passed intoinit
of DiffEq.
Interaction
The application is a standard AbstractPlotting scatterplot, which shows the PSOS of the system, initially using the system's u0
. Two sliders control the final evolution time and the size of the marker points.
Upon clicking within the bounds of the scatter plot your click is transformed into a new initial condition, which is further evolved and its PSOS is computed and then plotted into the scatter plot.
Your click is transformed into a full D
-dimensional initial condition through the function complete
. The first two arguments of the function are the positions of the click on the PSOS. The third argument is the value of the variable the PSOS is defined on. To be more exact, this is how the function is called:
x, y = mouseclick; z = plane[2] newstate = complete(x, y, z)
The complete
function can throw an error for ill-conditioned x, y, z
. This will be properly handled instead of breaking the application. This newstate
is also given to the function color
that gets a new color for the new points.
Function Video
using InteractiveChaos, Makie ds = Systems.henonheiles() potential(x, y) = 0.5(x^2 + y^2) + (x^2*y - (y^3)/3) energy(x,y,px,py) = 0.5(px^2 + py^2) + potential(x,y) const E = energy(get_state(ds)...) function complete(y, py, x) V = potential(x, y) Ky = 0.5*(py^2) Ky + V ≥ E && error("Point has more energy!") px = sqrt(2(E - V - Ky)) ic = [x, y, px, py] return ic end chaotic = get_state(ds) stable = [0., 0.1, 0.5, 0.] plane = (1, 0.0) psos = interactive_poincaresos(ds, plane, (2, 4), complete; markersizes = (-5, -1))