JuliaDynamics / InteractiveDynamics.jl

Fast, general-purpose interactive applications for complex systems
https://juliadynamics.github.io/InteractiveDynamics.jl/dev/
MIT License
174 stars 26 forks source link

How use Systems.henonheiles from InteractiveDynamics ? #53

Closed murrayE closed 3 years ago

murrayE commented 3 years ago

I’m trying to duplicate the first example of trajectory evolution in the docs for the InteractiveDynamcis package (https://juliadynamics.github.io/InteractiveDynamics.jl/dev/trajectory/).

I’ve already created an environment into which I’ve added InteractiveDynamics, DynamicalSystems, GLMakie, and OrdinaryDiffEq.

In that environment, I executed:

using InteractiveDynamics
using DynamicalSystems, GLMakie
using OrdinaryDiffEq

But when I try to execute next…

ds = Systems.henonheiles()

… I get error:

ERROR: UndefVarError: Systems not defined
Stacktrace:
 [1] top-level scope

What is Systems?

I tried to add a package named Systems but no such package was found.

Datseris commented 3 years ago

It's unlikely that you have actually installed DynamicalSystems.jl correctly. What does using DynamicalSystems do? Does it work? It exports the name Systems. What versions of the above packages are you using?

Datseris commented 3 years ago

This is what Systems is: https://juliadynamics.github.io/DynamicalSystems.jl/dev/ds/predefined/ To find it, go to the documentation of DynamicalSystems.jl and type "Systems" in the search bar.

murrayE commented 3 years ago

I added DynamicalSystems.js in the environment I created - the same one where I added InteractiveDynamics.jl, GLMakie.jl, and OrdinaryDiffEq. (This was upon advice I received elsewhere since otherwise, if I try to add them all in the default environment, I get version clashes involving Colors.)

Versions:

InteractiveDynamics: 0.14.6 DynamicalSystems: 1.7.6 OrdinaryDiffEq: 5.56.0

murrayE commented 3 years ago

Even the version 0.14.6 I'm using (which is what was added by default when I used add) allegedly includes Systems.henonheiles.

But the docs in ~/.julia/packages/DynamicalSystems/DTr2b/docs/src/ds/predefined.md say only:

# Predefined Dynamical Systems
Predefined systems exist in the `Systems` submodule in the form of functions that return a `DynamicalSystem`. They are accessed
like:
``````julia
using DynamicalSystems # or DynamicalSystemsBase
ds = Systems.lorenz(ρ = 32.0)

``So far, the predefined systems that exist in theSystems` sub-module are:

Modules = [Systems]
Order   = [:function]

How do I install the most recent, dev, version of InteractiveDynamics?

Datseris commented 3 years ago

But the docs in ~/.julia/packages/DynamicalSystems/DTr2b/docs/src/ds/predefined.md say only:

The docs don't have to say more, what they say is already 100% of the possible information you can receive. Systems is a submodule of the package DynamicalSystems, which contains pre-defined systems. There is truly nothing more to it.

If you indeed have DynamicalSystems version 1.7.6 installed, then you must be able to do:

using DynamicalSystems
Systems

and this will not error. Can you confirm?

In any case, your error is not related with a problem in InteractiveDynamics, nor DynamicalSystems. The docs are build automatically by running code, and if the documentation can find Systems, then you should be able to do as well. Perhaps something is wrong with your package installations and or versions.

murrayE commented 3 years ago

Not sure what I was doing wrong before, but now I am able to execute using DynamicalSystems then Systems without error.

However, now after also adding AbstractPlotting , executing...

using InteractiveDynamics
using DynamicalSystems, GLMakie
using OrdinaryDiffEq

ds = Systems.henonheiles()  # 4D chaotic/regular continuous system

u0s = [[0.0, -0.25, 0.42081, 0.0], [0.0, 0.1, 0.5, 0.0], [0.0, -0.31596, 0.354461, 0.0591255]]

diffeq = (alg = Vern9(), dtmax = 0.01)
idxs = (1, 2, 4)
colors = ["#233B43", "#499cbf", "#E84646"]

figure, obs = interactive_evolution(ds, u0s; idxs, tail = 10000, diffeq, colors)

...I get error:

ERROR: No backend available (GLMakie, CairoMakie, WGLMakie)!
Maybe you imported GLMakie but it didn't build correctly.
In that case, try `]build GLMakie` and watch out for any warnings.
If that's not the case, make sure to explicitely import any of the mentioned backends.

Stacktrace:
 [1] error(s::String)
   @ Base ./error.jl:33
 [2] backend_display(#unused#::Missing, #unused#::AbstractPlotting.Scene)
   @ AbstractPlotting ~/.julia/packages/AbstractPlotting/M8Nlv/src/display.jl:42
 [3] display
   @ ~/.julia/packages/AbstractPlotting/M8Nlv/src/display.jl:61 [inlined]
 [4] display
   @ ~/.julia/packages/AbstractPlotting/M8Nlv/src/display.jl:51 [inlined]
 [5] interactive_evolution(ds::ContinuousDynamicalSystem{true, Vector{Float64}, 4, typeof(DynamicalSystemsBase.Systems.hhrule!), Nothing, typeof(DynamicalSystemsBase.Systems.hhjacob!), Matrix{Float64}, false}, u0s::Vector{Vector{Float64}}; transform::typeof(identity), idxs::Tuple{Int64, Int64, Int64}, colors::Vector{String}, tail::Int64, diffeq::NamedTuple{(:alg, :dtmax), Tuple{Vern9, Float64}}, plotkwargs::NamedTuple{(), Tuple{}}, m::Float64, lims::Tuple{Tuple{Float64, Float64}, Tuple{Float64, Float64}, Tuple{Float64, Float64}})
   @ InteractiveDynamics ~/.julia/packages/InteractiveDynamics/BMtlp/src/chaos/trajanim.jl:83
 [6] top-level scope
   @ REPL[44]:1

So I did...

] build GLMakie
using GLMakie

... which said it built ModernGL. And then executing the same figure, obs = interactive_evolution( ... ) command again, I get exactly the same error.

I tried instead to use CairoMakie but got similar error.

I'm a rank Julia beginner and mightily confused here!

Datseris commented 3 years ago

Yeah, AbstractPlotting is obsolete. You need latest Makie.jl, version 0.13. You also need InteractiveDynamics 0.15. See also https://discourse.julialang.org/t/ann-makie-v-0-13/61522

murrayE commented 3 years ago

Does this mean that the docs at https://juliadynamics.github.io/InteractiveDynamics.jl/stable/trajectory/ need to be updated as to day to use Makie insteadl of GLMakie?

Datseris commented 3 years ago

No, the docs are correct. GLMakie provides a plotting backend, while Makie is the main plotting interface that is backend agnostic. Please be sure that you have the versions I cite above and everything will run.

murrayE commented 3 years ago

Yes, with Makie@0.13.11 and InteractiveDynamics@0.15.0 the example with the Henon system finally works for me. Thank you for your patient help!