diff --git a/examples/lyapunov/rabinovich_fabrikant_lyapunov.jl b/examples/lyapunov/rabinovich_fabrikant_lyapunov.jl index efd1741a..57903466 100644 --- a/examples/lyapunov/rabinovich_fabrikant_lyapunov.jl +++ b/examples/lyapunov/rabinovich_fabrikant_lyapunov.jl @@ -8,13 +8,9 @@ function RF(du, u, t) du[3] = -2*u[3]*(0.98+u[1]*u[2]) end + LE=FOLyapunov(RF, [0.999, 0.999, 0.999], 0, 0.02, 300, [0.1; 0.1; 0.1], 0.005, 1000) plot(LE) -plot(tspan, LE[1, :]) -plot!(tspan, LE[2, :]) -plot!(tspan, LE[3, :]) - - # Noncommensurate case @@ -26,4 +22,5 @@ function LE_RF_TEST(du, u, p, t) du[3] = -2*u[3]*(0.98+u[1]*u[2]) end LE = FOLyapunov(LE_RF_TEST, [0.995, 0.992, 0.996], 0, 0.1, 1000, [1,1,1], 0.01, 1000) -plot(LE) \ No newline at end of file +plot(LE) + diff --git a/src/lyapunov.jl b/src/lyapunov.jl index b71c238e..b4cceb1e 100644 --- a/src/lyapunov.jl +++ b/src/lyapunov.jl @@ -16,17 +16,18 @@ Computing fractional order Lyapunov exponent of a fractionl order system. """ function FOLyapunov(fun, order, t_start, h_norm, t_end, u0, h, out) if is_all_equal(order) + LE = commensurate_lyapunov(fun, order, t_start, h_norm, t_end, u0, h, out) else LE = noncommensurate_lyapunov(fun, order, t_start, h_norm, t_end, u0, h, out) end return LE + end @inline function is_all_equal(order::AbstractArray) length(order) < 2 && return true element1 = order[1] - @inbounds for i in eachindex(order) order[i] == element1 || return false end diff --git a/test/FOLEtest.jl b/test/FOLEtest.jl index 159876c6..1f4f307b 100644 --- a/test/FOLEtest.jl +++ b/test/FOLEtest.jl @@ -7,7 +7,7 @@ using Test du[2] = u[1]*(3*u[3]+1-u[1]*u[1])+0.1*u[2] du[3] = -2*u[3]*(0.98+u[1]*u[2]) end - + LE = FOLyapunov(RF, [0.999, 0.999, 0.999], 0, 0.02, 300, [0.1; 0.1; 0.1], 0.005, 1000) # Test the latest computed(final) Lyapunov exponents @@ -22,8 +22,8 @@ end du[2] = u[1]*(3*u[3]+1-u[1]^2) + 0.1*u[2] du[3] = -2*u[3]*(0.98+u[1]*u[2]) end - LE = FOLyapunov(LE_RF_TEST, [0.995, 0.992, 0.996], 0, 0.1, 1000, [1,1,1], 0.01, 1000) - + + LE = FOLyapunov(LE_RF_TEST, [0.995, 0.992, 0.996], 0, 0.1, 1000, [1,1,1], 0.01, 1000) @test isapprox(LE.LE[end-2:end], [-0.0033493403496077058 -0.0050780674255360226 -1.774132087623718]; atol=1e-3)