Skip to content

Commit c974d5f

Browse files
authored
update to julia v12 by removing all parallelizm from docs (#352)
* update to julia v12 by removing all parallelizm from docs * remove unecessary using from the test file
1 parent d4cc6cc commit c974d5f

File tree

4 files changed

+21
-27
lines changed

4 files changed

+21
-27
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "ChaosTools"
22
uuid = "608a59af-f2a3-5ad4-90b4-758bdf3122a7"
33
repo = "https://github.com/JuliaDynamics/ChaosTools.jl.git"
4-
version = "3.5.0"
4+
version = "3.5.1"
55

66
[deps]
77
Combinatorics = "861a8166-3701-5b0c-9a16-15d98fcdc6aa"

docs/src/chaos_detection.md

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -109,23 +109,21 @@ tands = TangentDynamicalSystem(ds; J = standardmap_jacob)
109109
dens = 101
110110
θs = ps = range(0, stop = 2π, length = dens)
111111
ics = vec(SVector{2, Float64}.(Iterators.product(θs, ps)))
112-
# Initialize as many systems as threads
113-
systems = [deepcopy(tands) for _ in 1:Threads.nthreads()-1]
114-
pushfirst!(systems, tands)
115-
# Perform threaded loop
112+
# Perform loop
116113
regularity = zeros(size(ics))
117-
Threads.@threads for i in eachindex(ics)
114+
for i in eachindex(ics)
118115
u0 = ics[i]
119-
system = systems[Threads.threadid()]
120-
reinit!(system, u0)
121-
regularity[i] = gali(system, 500)[2][end]
116+
reinit!(ds, u0)
117+
regularity[i] = gali(ds, 500)[2][end]
122118
end
123119
# Visualize
124120
fig, ax, sc = scatter(ics; color = regularity)
125121
Colorbar(fig[1,2], sc; label = "regularity")
126122
fig
127123
```
128124

125+
You can parallelize this code as well, see the main tutorial of DynamicalSystems.jl for an example.
126+
129127
## Predictability of a chaotic system
130128

131129
Even if a system is "formally" chaotic, it can still be in phases where it is partially

docs/src/lyapunovs.md

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,7 @@ tands = TangentDynamicalSystem(ds; J = towel_jacob)
6060
966.500 μs (10 allocations: 576 bytes) # on my laptop
6161
```
6262

63-
Here is an example of using [`reinit!`](@ref) to efficiently iterate over different parameter values, and parallelize via `Threads`, to compute the exponents over a given parameter range.
64-
63+
Here is an example of using [`reinit!`](@ref) to iterate over different parameter values to compute the exponents over a given parameter range.
6564

6665
```@example MAIN
6766
using ChaosTools, CairoMakie
@@ -74,14 +73,9 @@ tands = TangentDynamicalSystem(ds; J = henon_jacob)
7473
as = 0.8:0.005:1.225;
7574
λs = zeros(length(as), 2)
7675
77-
# Since `DynamicalSystem`s are mutable, we need to copy to parallelize
78-
systems = [deepcopy(tands) for _ in 1:Threads.nthreads()-1]
79-
pushfirst!(systems, tands)
80-
81-
Threads.@threads for i in eachindex(as)
82-
system = systems[Threads.threadid()]
83-
set_parameter!(system, 1, as[i])
84-
λs[i, :] .= lyapunovspectrum(system, 10000; Ttr = 500)
76+
for i in eachindex(as)
77+
set_parameter!(ds, 1, as[i])
78+
λs[i, :] .= lyapunovspectrum(ds, 10000; Ttr = 500)
8579
end
8680
8781
fig = Figure()
@@ -92,6 +86,8 @@ end
9286
fig
9387
```
9488

89+
You can parallelize this code as well, see the main tutorial of DynamicalSystems.jl for an example.
90+
9591
## Maximum Lyapunov Exponent
9692

9793
It is possible to get only the maximum Lyapunov exponent simply by giving
@@ -216,7 +212,7 @@ pidx = 3 # set to dummy, not used anywhere (no drift)
216212
ρ,times = ensemble_averaged_pairwise_distance(ds,init_states,100,pidx;Ttr=5000)
217213
λ_inst = lyapunov_instant(ρ,times;interval=20:30) #fit to middle part of the curve (slope is constant until saturation)
218214
λ = lyapunov(ds,1000;Ttr=5000) #standard (Benettin) way
219-
@show λ_inst, λ
215+
@show λ_inst, λ
220216
```
221217

222218
Now look at the nonautonomous Duffing map with drifting ε parameter:
@@ -236,17 +232,17 @@ end
236232
return SVector(dx1, dx2)
237233
end
238234
239-
duffing = duffing_drift()
235+
duffing = duffing_drift()
240236
duffing_map = StroboscopicMap(duffing,2π)
241-
init_states = randn(5000,2) #use an ensemble of 5000
237+
init_states = randn(5000,2) #use an ensemble of 5000
242238
pidx = 4 #ε is the fourth parameter
243239
ρ,times = ensemble_averaged_pairwise_distance(duffing_map,StateSpaceSet(init_states),100,pidx;Ttr=20)
244240
245-
#measure slope of ρ at two places
241+
#measure slope of ρ at two places
246242
λ_inst = lyapunov_instant(ρ,times;interval=5:10)
247243
λ_inst2 = lyapunov_instant(ρ,times;interval=22:25)
248244
249-
fig,ax,obj = scatter(times, ρ,
245+
fig,ax,obj = scatter(times, ρ,
250246
markersize = 6,
251247
color = :gray10,
252248
label = L"\omega = 1, \beta = 0.2, \epsilon_0 = 0.4, \alpha=0.00045",
@@ -258,7 +254,7 @@ lines!(ax, times[22:25], ρ[22] .+ λ_inst2*[0:3;],color = (:red, 0.7), linewidt
258254
text!(ax, times[5]+8, ρ[10],text = L"\lambda = %$(round(λ_inst;digits=3))",
259255
color = :red,align = (:left, :center),fontsize = 18)
260256
261-
text!(ax, times[22]+8, ρ[24],text = L"\lambda = %$(round(λ_inst2;digits=3))",
257+
text!(ax, times[22]+8, ρ[24],text = L"\lambda = %$(round(λ_inst2;digits=3))",
262258
color = :red, align = (:left, :center), fontsize = 18)
263259
264260
axislegend(ax, position = :rb, nbanks = 2,labelsize = 18)

test/chaosdetection/lyapunovs.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using ChaosTools, Test, DynamicalSystemsBase
1+
using ChaosTools, Test
22
using DelayEmbeddings: embed
33
import Statistics
44

@@ -111,6 +111,6 @@ end
111111
@testset "testSuccessfulStep" begin
112112
u0 = [NaN, 0]
113113
p0 = [0.1, -0.4]
114-
ds = CoupledODEs(trivial_rule, u0, p0)
114+
ds = CoupledODEs(trivial_rule, u0, p0)
115115
@test isnan(lyapunov(ds, 10; Ttr = 0, Δt = 0.5))
116116
end

0 commit comments

Comments
 (0)