Skip to content

Commit

Permalink
Merge branch 'master' into noncommensurate
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikQQY authored Apr 26, 2023
2 parents 916b24d + f21d3e2 commit 89f3766
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
9 changes: 3 additions & 6 deletions examples/lyapunov/rabinovich_fabrikant_lyapunov.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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)
plot(LE)

3 changes: 2 additions & 1 deletion src/lyapunov.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions test/FOLEtest.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down

0 comments on commit 89f3766

Please sign in to comment.