-
Notifications
You must be signed in to change notification settings - Fork 43
Instantaneous Lyapunov exponent for systems with parameter drift #345
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
8752220
add EAPD
rusandris 6e4fd9f
revised version and tests (still need docs)
rusandris 6460a9a
add some docstrings
rusandris 5009e5f
fix docstring part
rusandris a51d9b8
Merge branch 'JuliaDynamics:main' into main
rusandris c3560df
include EAPD test
rusandris 9ba8de6
minor fixes, improve docstring, tests
rusandris 33facf3
Merge branch 'main' of https://github.com/rusandris/ChaosTools.jl
rusandris 08d3e0d
fix dummy parameter test
rusandris 90d71de
increase tolerance for testing
rusandris f95ed1b
Update lyapunovs.jl: relax test
Datseris 09e11f4
fix comment
rusandris 5ae55a0
add EAPD to docs
rusandris a30fa7c
Merge branch 'main' of https://github.com/rusandris/ChaosTools.jl
rusandris d2dc1f7
fix citation
rusandris 9dca714
add changelog and increase version number
rusandris 2aab94e
correct vertsion number
Datseris 82fdf05
Correct version number
Datseris File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
export EAPD,lyapunov_instant | ||
|
||
#slopefit to ρ(t) curve -> instantaneous Lyapunov exponent | ||
function lyapunov_instant(ρ,times;interval=1:length(times)) | ||
rusandris marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
s,_,_ = slopefit(times[interval], ρ[interval]) #return estimated slope and confidence intervals | ||
return s | ||
end | ||
|
||
#Ensemble-averaged pairwise distance (EAPD) -> ρ(t),t | ||
function EAPD(ds,init_states::Matrix,T;sliding_param_rate_index=0,initial_params = deepcopy(current_parameters(ds)),Ttr,Δt = 1,ϵ=sqrt(2)*1e-10) | ||
Datseris marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
set_parameters!(ds,initial_params) | ||
N,d = size(init_states) | ||
dimension(ds) != d && throw(AssertionError("Dimension of `ds` doesn't match dimension of states in init_states!")) | ||
|
||
nt = length(0:Δt:T) #number of time steps | ||
ρ = zeros(nt) #store ρ(t) | ||
times = zeros(nt) #store t | ||
|
||
#duplicate every state | ||
#(add test particle to every ensemble member) | ||
init_states_plus_copies = StateSpaceSet(vcat(init_states,init_states)) | ||
|
||
#create a pds for the ensemble | ||
#pds is a ParallelDynamicalSystem | ||
pds = ParallelDynamicalSystem(ds,init_states_plus_copies) | ||
|
||
#set to non-drifting for initial ensemble | ||
set_parameter!(pds,sliding_param_rate_index,0.0) | ||
@show current_parameters(pds) | ||
|
||
#step system pds to reach attractor(non-drifting) | ||
#system starts to drift at t0=0.0 | ||
for _ in 0:Δt:Ttr | ||
step!(pds,Δt,true) | ||
end | ||
|
||
#rescale test states | ||
#add perturbation to test states | ||
for i in 1:N | ||
state_i = current_state(pds,i) | ||
perturbed_state_i = state_i .+ perturbation(ds,ϵ) | ||
#set_state!(pds.systems[N+i],perturbed_state_i) | ||
set_state!(pds,perturbed_state_i,N+i) | ||
end | ||
|
||
#set to drifting for initial ensemble | ||
set_parameters!(pds,initial_params) | ||
|
||
#set back time to t0 = 0 | ||
reinit!(pds,current_states(pds)) | ||
|
||
#function barrier here? | ||
#calculate EAPD for each time step | ||
EAPD!(ρ,times,pds,T,Δt) | ||
return ρ,times | ||
|
||
end | ||
|
||
#calc distance for every time step until T | ||
function EAPD!(ρ,times,pds,T,Δt) | ||
for (i,t) in enumerate(0:Δt:T) | ||
ρ[i] = EAPD(pds) | ||
times[i] = current_time(pds) | ||
step!(pds,Δt,true) | ||
end | ||
end | ||
|
||
#calc distance for current states of pds | ||
function EAPD(pds) | ||
|
||
states = current_states(pds) | ||
N = Int(length(states)/2) | ||
|
||
#calculate distance averages | ||
ρ = 0.0 | ||
for i in 1:N | ||
ρ += log.(norm(states[i] - states[N+i])) | ||
end | ||
return ρ/N | ||
|
||
end | ||
|
||
function perturbation(ds,ϵ) | ||
D, T = dimension(ds), eltype(ds) | ||
Q0 = randn(SVector{D, T}) | ||
Q0 = ϵ * Q0 / norm(Q0) | ||
Datseris marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
end |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.