Comments (3)
From @SebastianM-C on October 2, 2017 22:54
I implemented the naive way using pmap
in order to reduce the time by parallelization.
I used a the following wrapper around lyapunov
in order to work directly on ODEProblem
s
function compute_lyapunov(prob::ODEProblem; d0=1e-9, threshold=10^4*d0, dt = 0.1,
diff_eq_kwargs = Dict(:abstol=>d0, :reltol=>d0))
threshold <= d0 && throw(ArgumentError("Threshold must be bigger than d0!"))
if haskey(diff_eq_kwargs, :solver)
solver = diff_eq_kwargs[:solver]
else
println("Using DPRKN12 as default solver")
solver = DPRKN12()
end
# Initialize
st1 = prob.u0
integ1 = init(prob, solver; diff_eq_kwargs..., save_first=false, save_everystep=false)
integ1.opts.advance_to_tstop = true
prob.u0 = st1 .+ d0
integ2 = init(prob, solver; diff_eq_kwargs..., save_first=false, save_everystep=false)
integ2.opts.advance_to_tstop = true
prob.u0 = st1
lyapunov(integ1, integ2, prob.tspan[2]; d0=d0, threshold=threshold, dt=dt)
end
Then I use the following function for the parallel λ computations
function compute_λs(q0list, p0list, tmax, d0, dt, tr, kwargs, prefix)
n = size(q0list, 1) # number of initial conditions
λs = SharedArray{Float64}(n)
pmap(i->(prob = defProb(q0list[i,:], p0list[i,:], (0., tmax));
λs[i] = compute_lyapunov(prob, d0=d0, dt=dt, threshold=tr,
diff_eq_kwargs=kwargs)),
Progress(n),
1:n)
save("$prefix/lyapunov.jld", "λs", λs, "d0", d0, "dt", dt, "tr", tr,
"tmax", tmax, "n", n);
return λs
end
in a function like this
addprocs(4);
using JLD
using ArgParse
using Plots, LaTeXStrings
using ProgressMeter
using PmapProgressMeter
@everywhere begin
using OrdinaryDiffEq, DiffEqCallbacks
using ParallelDataTransfer
end
function main()
# Hamiltonian parameters
A, B, D = readdlm("param.dat")
E_list, tmax, d0, dt, tr, solver, kwargs, defProb = input_param()
# Broadcast parameters to all workers
sendto(workers(), A=A, B=B, D=D, defProb=defProb)
for E in E_list
sendto(workers(), E=E)
prefix = "../output/B$B D$D E$E"
if !isdir(prefix)
mkpath(prefix)
end
if isfile("$prefix/z0.jld")
q0list, p0list = load("$prefix/z0.jld", "q0list", "p0list")
else
error("$prefix/z0.jld not found! Generate the initial conditions.")
end
λs = compute_λs(q0list, p0list, tmax, d0, dt, tr, kwargs, prefix)
end
end
where the initial conditions are read from a file.
from chaostools.jl.
Thanks! There may be better approaches or algorithms I am not aware of, but on the very least your code gives a concrete start for a general parallelized interface in case a different approach is not found!
from chaostools.jl.
This is implemented as local_growth_rates
.
from chaostools.jl.
Related Issues (20)
- Support for very high-dimensional systems in `lyapunovspectrum`/ usage of DDEs HOT 10
- `AttractorsViaRecurrences` has trouble when systems have fast and slow dynamics HOT 8
- setindex!(::SVector{3, Float64}, value, ::Int) is not defined when trying to use a non-default solver HOT 3
- Improve the tests, like, a lot.
- Basins labels for supervised clustering method
- The unsupervised method for `AttractorsViaFeaturizing` is slow
- Standing TODOs for `RecurrencesSeededContinuation`
- Allow for hyper-rectanges in new code for return times in continuous time systems
- Allow arbitrary initial condition in `exit_entry_times`
- local_growth_rates does not work with non-adaptive solver HOT 1
- Lyapunov exponent of stroboscopic map perhaps incorrect? HOT 3
- lyapunovspectrum for k less than dimension
- typos HOT 4
- `k` parameter in `lyapunovspectrum` HOT 1
- Covariant Lyapunov Vectors from data using SVD
- Wrong lyapunov exponent of unstable systems when the solver works adaptively HOT 3
- Ordinal Poincaré sections: Reconstructing the first return map from an ordinal segmentation of time series
- Improving the speed of Lyapunov spectra computation
- saving the trajectory from Lyapunov spectrum calculation HOT 4
- Collection of the Lyapunov exponents over time HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from chaostools.jl.