Skip to content

Commit

Permalink
Fix in Lyapunov spectrum caches
Browse files Browse the repository at this point in the history
  • Loading branch information
PerezHz committed Jan 6, 2025
1 parent 617cafb commit d7d4769
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/integrator/cache.jl
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,9 @@ function init_cache_lyap(t0::T, q0::Vector{U}, maxsteps::Int, order::Int) where
# Initialize the vector of Taylor1 expansions
dof = length(q0)
jt = Matrix{U}(I, dof, dof)
x0 = vcat(q0, reshape(jt, dof*dof))
x0 = similar(q0, dof + dof*dof)
x0[1:dof] .= q0
@views x0[dof+1:end] .= jt[:]
t, x, dx = init_expansions(t0, x0, order)
# Initialize cache
nx0 = length(x0)
Expand Down Expand Up @@ -233,7 +235,9 @@ function init_cache_lyap(trange::AbstractVector{T}, q0::Vector{U}, maxsteps::Int
t0 = trange[1]
dof = length(q0)
jt = Matrix{U}(I, dof, dof)
x0 = vcat(q0, reshape(jt, dof*dof))
x0 = similar(q0, dof + dof*dof)
x0[1:dof] .= q0
@views x0[dof+1:end] .= jt[:]
t, x, dx = init_expansions(t0, x0, order)
# Initialize cache
nn = length(trange)
Expand All @@ -244,7 +248,7 @@ function init_cache_lyap(trange::AbstractVector{T}, q0::Vector{U}, maxsteps::Int
Array{U}(undef, dof, nn),
nothing,
Array{Taylor1{U}}(undef, nx0),
similar(x0),
x0,
similar(q0),
Array{U}(undef, dof, nn),
similar(q0),
Expand Down
6 changes: 6 additions & 0 deletions src/lyapunovspectrum.jl
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,9 @@ function lyap_taylorinteg!(f!,

# Initial conditions
sign_tstep = copysign(1, tmax-t0)
x0[1:dof] .= q0
@views x0[dof+1:end] .= jt[:]
update!(cache, t0, x0)
t00 = t0
tspan = zero(T)
@inbounds tv[1] = t0
Expand Down Expand Up @@ -374,6 +377,9 @@ function lyap_taylorinteg!(f!,
# Initial conditions
@inbounds t0, t1, tmax = trange[1], trange[2], trange[end]
sign_tstep = copysign(1, tmax-t0)
x0[1:dof] .= q0
@views x0[dof+1:end] .= jt[:]
update!(cache, t0, x0)
t00 = t0
tspan = zero(T)
@inbounds for ind in eachindex(q0)
Expand Down

0 comments on commit d7d4769

Please sign in to comment.