JuliaDynamics/DynamicalSystems.jl

integrator-using functions should return NaN on non-successful integrator steps

Open

#184 aperta il 8 giu 2022

Vedi su GitHub
 (24 commenti) (0 reazioni) (0 assegnatari)Julia (102 fork)batch import
designgood first issuequality of life

Metriche repository

Star
 (928 star)
Metriche merge PR
 (Nessuna PR mergiata in 30 g)

Descrizione

Hello again!

Now I try to calculate the Lyapunov spectrum in a two-parameter plane. But a warning comes when I choose some of the parameter regions:

Warning: Instability detected. Aborting

From what I googled, the warning comes because it returns a NAN in the trajectory. I am thinking if I can use the 'isnan' function to skip those parameter sets that cause the NAN and continue my loop. Since the lyapunovspectrum function is built-in, I am looking for your help.

Here is my code:

using DynamicalSystems, CairoMakie, GLMakie
using OrdinaryDiffEq
using DelimitedFiles
using ProgressMeter
function chaotictest(u, p, t)
    k1, k2 = p
    x, y, z = u
    dx = y
    dy = z
    dz = k1-7*y+x^2+k2*z
    return SVector(dx, dy, dz)
end
u0 = [0.01, 0.01, 0.01]
para = [-1.0, -1.0] 
ds = ContinuousDynamicalSystem(chaotictest, u0, para)
diffeq = (alg = Tsit5(), adaptive = false, dt = 0.001)
as = -1:0.1:8;  
bs = -1.0:0.05:0.01;
nloop = length(as)*length(bs)
cordiλ = zeros(nloop, 2+3)
λs = zeros(nloop, 3)
paras = zeros(nloop, 2)
cirnum = 0
prog = Progress(nloop; showspeed=true)
for (i, a) in enumerate(as)
    for (j, b) in enumerate(bs)
         global cirnum = cirnum + 1
    set_parameter!(ds, 1, a)
    set_parameter!(ds, 2, b)  
    λs[cirnum, :] .= lyapunovspectrum(ds, 2000; Ttr=3000, diffeq)
    paras[cirnum, :] .= [a, b]
    global cordiλ = [paras λs]
    next!(prog)
end
end

Guida contributor