# Can not choose alg for lyapunovspectrum DynamicalSystems.jl

**URL:** <https://discourse.julialang.org/t/can-not-choose-alg-for-lyapunovspectrum-dynamicalsystems-jl/85173>\
**Category:** Modelling & Simulations\
**Created:** [August 2, 2022, 3:32pm UTC](https://discourse.julialang.org/t/can-not-choose-alg-for-lyapunovspectrum-dynamicalsystems-jl/85173 "2022-08-02T15:32:28Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sergey\_Novak](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sergey_novak/32/37716_2.png) [@Sergey\_Novak](https://discourse.julialang.org/u/Sergey_Novak)\
**Post date:** [August 2, 2022, 3:32pm UTC](https://discourse.julialang.org/t/can-not-choose-alg-for-lyapunovspectrum-dynamicalsystems-jl/85173/1 "2022-08-02T15:32:28Z")

</div>

I have system and parametres:

```julia
function HR!(du, u, p, t)
    
    function sigma(x)
            return 1.0 / ( 1.0 + exp( -10.0 * ( x - ( - 0.25 ) ) ) )
    end
    
    a, b, c, d, s, xr, r, I, vs, k1, k2, el_link = p
    x1, y1, z1, x2, y2, z2 = u
    
    du[1] = y1 + b * x1 ^ 2 - a * x1 ^3 - z1 + I - k1 * ( x1 - vs ) * sigma(x2) + el_link * ( x2 - x1 )
    du[2] = c - d * x1 ^2 - y1
    du[3] = r * ( s * ( x1 - xr ) - z1 )
    
    du[4] = y2 + b * x2 ^ 2 - a * x2 ^3 - z2 + I - k2 * ( x2 - vs ) * sigma(x1) + el_link * ( x1 - x2 )
    du[5] = c - d * x2 ^2 - y2
    du[6] = r * ( s * ( x2 - xr ) - z2 )
    
    return SVector(du[1], du[2], du[3],
                    du[4], du[5], du[6])
end

tspan = (0., 50000.)

a = 1.
b = 3.
c = 1.
d = 5.
xr = -1.6
r = 0.01 # 0.01
s = 5.
I = 4.
xv = 2.

k1= -0.17
k2 = k1

```

I try calculate lyapunov spectrum with this code

```julia
p = [a, b, c, d,
        s, xr, r, I, xv, k1, k2, 0]
initialcondition = [-0.469412067339509, -0.5839635169884322, 4.025111076102515, -0.469412067339509, -0.5839635169884322, 4.025111076102515]
ds_HR = ContinuousDynamicalSystem(HR!, initialcondition, p )

spectrum = lyapunovspectrum(ds_HR, tspan[2]; diffeq = (alg = AutoVern9(Rodas5()), maxiters = 10000000))

```

and get next error:

 ![image](https://global.discourse-cdn.com/julialang/original/3X/d/8/d8ef3586a1eb1caf808b1c44ec8fac4b35e77caf.png)

---

<div class="post-metadata">

**Author:** ![Datseris](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/datseris/32/13406_2.png) [@Datseris](https://discourse.julialang.org/u/Datseris)\
**Post date:** [August 2, 2022, 5:34pm UTC](https://discourse.julialang.org/t/can-not-choose-alg-for-lyapunovspectrum-dynamicalsystems-jl/85173/2 "2022-08-02T17:34:44Z")

</div>

Please see [Please read: make it easier to help you](https://discourse.julialang.org/t/please-read-make-it-easier-to-help-you/14757) and update the post accordingly in order to get an answer quicker 🙂

(my bet is that when you defined the dynamic rule you annotated types)

---

<div class="post-metadata">

**Author:** ![Sergey\_Novak](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sergey_novak/32/37716_2.png) [@Sergey\_Novak](https://discourse.julialang.org/u/Sergey_Novak)\
**Post date:** [August 2, 2022, 5:44pm UTC](https://discourse.julialang.org/t/can-not-choose-alg-for-lyapunovspectrum-dynamicalsystems-jl/85173/3 "2022-08-02T17:44:39Z")

</div>

I updated, sorry

---

<div class="post-metadata">

**Author:** ![Datseris](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/datseris/32/13406_2.png) [@Datseris](https://discourse.julialang.org/u/Datseris)\
**Post date:** [August 2, 2022, 6:00pm UTC](https://discourse.julialang.org/t/can-not-choose-alg-for-lyapunovspectrum-dynamicalsystems-jl/85173/4 "2022-08-02T18:00:49Z")

</div>

what happens when you do `integrator(ds)` and then `step!(integ)`?

---

<div class="post-metadata">

**Author:** ![Sergey\_Novak](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sergey_novak/32/37716_2.png) [@Sergey\_Novak](https://discourse.julialang.org/u/Sergey_Novak)\
**Post date:** [August 2, 2022, 7:03pm UTC](https://discourse.julialang.org/t/can-not-choose-alg-for-lyapunovspectrum-dynamicalsystems-jl/85173/5 "2022-08-02T19:03:08Z")

</div>

I was randomly able to correct this error. Why that fixed i don’t understand

 ![image](https://global.discourse-cdn.com/julialang/original/3X/0/1/01f916799c5b7de945a51701bd3a3fc11ae4b0ca.png)

---

<div class="post-metadata">

**Author:** ![Sergey\_Novak](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sergey_novak/32/37716_2.png) [@Sergey\_Novak](https://discourse.julialang.org/u/Sergey_Novak)\
**Post date:** [August 2, 2022, 7:13pm UTC](https://discourse.julialang.org/t/can-not-choose-alg-for-lyapunovspectrum-dynamicalsystems-jl/85173/6 "2022-08-02T19:13:40Z")

</div>

May I ask one more slightly off-topic question, so as not to create a new topic? It is related to the Lyapunov spectrum

---

<div class="post-metadata">

**Author:** ![Datseris](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/datseris/32/13406_2.png) [@Datseris](https://discourse.julialang.org/u/Datseris)\
**Post date:** [August 2, 2022, 7:43pm UTC](https://discourse.julialang.org/t/can-not-choose-alg-for-lyapunovspectrum-dynamicalsystems-jl/85173/7 "2022-08-02T19:43:21Z")

</div>

sure, also consider joining the `dynamics-bridged` channel on the julia slack

---

<div class="post-metadata">

**Author:** ![Sergey\_Novak](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sergey_novak/32/37716_2.png) [@Sergey\_Novak](https://discourse.julialang.org/u/Sergey_Novak)\
**Post date:** [August 2, 2022, 8:04pm UTC](https://discourse.julialang.org/t/can-not-choose-alg-for-lyapunovspectrum-dynamicalsystems-jl/85173/8 "2022-08-02T20:04:20Z")

</div>

Okay, thank you. I read about reinit! but i don’t understand how correctly used him for this code

```julia
for (i, k) in enumerate(k_space)
    if i == 1
        global initialcondition = [-1.5, 0.0, 0.0, -2.5, 0.0, 0.0] # [0.1, 0.2, 0.3, 0.4, 0.05, 0.6]
    end
    println("Initial condition: $initialcondition"); flush(stdout)
    println("k: $k"); flush(stdout)
    
    p = [a, b, c, d,
        s, xr, r, I, xv, k1, k2, k]
    prob = ODEProblem(HR!, initialcondition, tspan, p)
    sol = solve(prob, AutoVern9(Rodas5()), abstol = 1e-11, reltol = 1e-11, maxiters = 10000000)
   
    ds_HR = ContinuousDynamicalSystem(HR!, initialcondition, p )
    spectrum = lyapunovspectrum(ds_HR, tspan[2]; diffeq = (alg = AutoVern9(Rodas5()), abstol = 1e-11, reltol = 1e-11, maxiters = 10000000))
    spectrum_array[1:3, i] = spectrum[1:3]
    
    println("Spectrum: ", spectrum_array[1:3, i]); flush(stdout)
    
    initialcondition = sol[length(sol.u)]
    
    println("Last point: ", initialcondition); flush(stdout)
    
    println(">>>>>>>>>>>>>>>"); flush(stdout)
    println(""); flush(stdout)
    
end

```

This evolution of lyapunov sprectrum with inheritance of initial conditions and change of one parameter

---

<div class="post-metadata">

**Author:** ![Datseris](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/datseris/32/13406_2.png) [@Datseris](https://discourse.julialang.org/u/Datseris)\
**Post date:** [August 2, 2022, 9:02pm UTC](https://discourse.julialang.org/t/can-not-choose-alg-for-lyapunovspectrum-dynamicalsystems-jl/85173/9 "2022-08-02T21:02:40Z")

</div>

see [Integrators · DynamicalSystems.jl](https://juliadynamics.github.io/DynamicalSystems.jl/dev/ds/integrators/#Re-initializing-an-integrator)

---

<div class="post-metadata">

**Author:** ![Sergey\_Novak](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sergey_novak/32/37716_2.png) [@Sergey\_Novak](https://discourse.julialang.org/u/Sergey_Novak)\
**Post date:** [August 3, 2022, 7:46am UTC](https://discourse.julialang.org/t/can-not-choose-alg-for-lyapunovspectrum-dynamicalsystems-jl/85173/10 "2022-08-03T07:46:32Z")

</div>

Okay, thank you.
