JuliaDynamics / ChaosTools.jl

Tools for the exploration of chaos and nonlinear dynamics
https://juliadynamics.github.io/DynamicalSystemsDocs.jl/chaostools/stable/
MIT License
188 stars 36 forks source link

`k` parameter in `lyapunovspectrum` #307

Closed MA-Ramirez closed 1 year ago

MA-Ramirez commented 1 year ago

Hello,

Describe the bug It is not possible to modify the k parameter in lyapunovspectrum

Minimal Working Example

using DynamicalSystems
ds = PredefinedDynamicalSystems.lorenz()
lyapunov_spectrum = lyapunovspectrum(ds, 10000;  k=2)

Error

MethodError: no method matching lyapunovspectrum(::TangentDynamicalSystem{false, CoupledODEs{false, 12, OrdinaryDiffEq.ODEIntegrator{OrdinaryDiffEq.Tsit5{typeof(OrdinaryDiffEq.trivial_limiter!), typeof(OrdinaryDiffEq.trivial_limiter!), Static.False}, false, SMatrix{3, 4, Float64, 12}, Nothing, Float64, Vector{Float64}, Float64, Float64, Float64, Float64, Vector{SMatrix{3, 4, Float64, 12}}, SciMLBase.ODESolution{Float64, 3, Vector{SMatrix{3, 4, Float64, 12}}, Nothing, Nothing, Vector{Float64}, Vector{Vector{SMatrix{3, 4, Float64, 12}}}, SciMLBase.ODEProblem{SMatrix{3, 4, Float64, 12}, Tuple{Float64, Float64}, false, Vector{Float64}, SciMLBase.ODEFunction{false, SciMLBase.AutoSpecialize, DynamicalSystemsBase.TangentOOP{typeof(PredefinedDynamicalSystems.lorenz_rule), DynamicalSystemsBase.var"#64#66"{typeof(PredefinedDynamicalSystems.lorenz_rule)}, 3}, LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing, Nothing}, Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, SciMLBase.StandardODEProblem}, OrdinaryDiffEq.Tsit5{typeof(OrdinaryDiffEq.trivial_limiter!), typeof(OrdinaryDiffEq.trivial_limiter!), Static.False}, OrdinaryDiffEq.InterpolationData{SciMLBase.ODEFunction{false, SciMLBase.AutoSpecialize, DynamicalSystemsBase.TangentOOP{typeof(PredefinedDynamicalSystems.lorenz_rule), DynamicalSystemsBase.var"#64#66"{typeof(PredefinedDynamicalSystems.lorenz_rule)}, 3}, LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing, Nothing}, Vector{SMatrix{3, 4, Float64, 12}}, Vector{Float64}, Vector{Vector{SMatrix{3, 4, Float64, 12}}}, OrdinaryDiffEq.Tsit5ConstantCache}, DiffEqBase.Stats, Nothing}, SciMLBase.ODEFunction{false, SciMLBase.AutoSpecialize, DynamicalSystemsBase.TangentOOP{typeof(PredefinedDynamicalSystems.lorenz_rule), DynamicalSystemsBase.var"#64#66"{typeof(PredefinedDynamicalSystems.lorenz_rule)}, 3}, LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing, Nothing}, OrdinaryDiffEq.Tsit5ConstantCache, OrdinaryDiffEq.DEOptions{Float64, Float64, Float64, Float64, OrdinaryDiffEq.PIController{Rational{Int64}}, typeof(DynamicalSystemsBase.matrixnorm), typeof(LinearAlgebra.opnorm), Bool, SciMLBase.CallbackSet{Tuple{}, Tuple{}}, typeof(DiffEqBase.ODE_DEFAULT_ISOUTOFDOMAIN), typeof(DiffEqBase.ODE_DEFAULT_PROG_MESSAGE), typeof(DiffEqBase.ODE_DEFAULT_UNSTABLE_CHECK), DataStructures.BinaryHeap{Float64, DataStructures.FasterForward}, DataStructures.BinaryHeap{Float64, DataStructures.FasterForward}, Nothing, Nothing, Float64, Tuple{}, Tuple{}, Tuple{}}, SMatrix{3, 4, Float64, 12}, Float64, Nothing, OrdinaryDiffEq.DefaultInit}, Vector{Float64}}}, ::Int64; k=1)
Closest candidates are:
  lyapunovspectrum(::TangentDynamicalSystem, ::Int64; Δt, Ttr, show_progress, u0) at [~/.julia/packages/ChaosTools/VMXUY/src/chaosdetection/lyapunovs/lyapunovspectrum.jl:67](https://file+.vscode-resource.vscode-cdn.net/Users/bacalao/Documents/Research/Arne/Chaos_Project/ChaosNoiseEGT/notebooks/~/.julia/packages/ChaosTools/VMXUY/src/chaosdetection/lyapunovs/lyapunovspectrum.jl:67) got unsupported keyword argument "k"
  lyapunovspectrum(!Matched::CoreDynamicalSystem, ::Any) at [~/.julia/packages/ChaosTools/VMXUY/src/chaosdetection/lyapunovs/lyapunovspectrum.jl:52](https://file+.vscode-resource.vscode-cdn.net/Users/bacalao/Documents/Research/Arne/Chaos_Project/ChaosNoiseEGT/notebooks/~/.julia/packages/ChaosTools/VMXUY/src/chaosdetection/lyapunovs/lyapunovspectrum.jl:52) got unsupported keyword argument "k"
  lyapunovspectrum(!Matched::CoreDynamicalSystem, ::Any, !Matched::Any; kwargs...) at [~/.julia/packages/ChaosTools/VMXUY/src/chaosdetection/lyapunovs/lyapunovspectrum.jl:52](https://file+.vscode-resource.vscode-cdn.net/Users/bacalao/Documents/Research/Arne/Chaos_Project/ChaosNoiseEGT/notebooks/~/.julia/packages/ChaosTools/VMXUY/src/chaosdetection/lyapunovs/lyapunovspectrum.jl:52)

It works by using the following code:

tands = TangentDynamicalSystem(ds; k=2)
lyapunov_spectrum = lyapunovspectrum(tands, 10000)

Package versions Julia v1.8.5 DynamicalSystems v3.0.0

Cheers

Datseris commented 1 year ago

In https://juliadynamics.github.io/ChaosTools.jl/stable/lyapunovs/#ChaosTools.lyapunovspectrum k isn't a keyword, it is an optional argument. Try instead lyapunov_spectrum = lyapunovspectrum(ds, 10000, 2) and it will work.