Skip to content

Commit 4d7e5f2

Browse files
github-actions[bot]CompatHelper Juliaoameyereykboerner
authored
CompatHelper: bump compat for IntervalArithmetic to 0.22, (keep existing compat) (#129)
* CompatHelper: bump compat for IntervalArithmetic to 0.22, (keep existing compat) * fix intervals_to_box to work with IntervalArithmatics 0.22 * fix some of the tests * replace CoupledSDEsBasin extension with AttractorsExt * fixed import * Update Project.toml * format * fix docs make * updated docs --------- Co-authored-by: CompatHelper Julia <compathelper_noreply@julialang.org> Co-authored-by: Orjan Ameye <orjan.ameye@hotmail.com> Co-authored-by: reykboerner <reyk.boerner@reading.ac.uk>
1 parent 09bc764 commit 4d7e5f2

17 files changed

+94
-792
lines changed

Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ StateSpaceSets = "40b095a5-5852-4c12-98c7-d43bf788e795"
3333

3434
[extensions]
3535
ChaosToolsExt = ["ChaosTools"]
36-
CoupledSDEsBasin = ["ChaosTools", "Attractors"]
36+
AttractorsExt = ["Attractors"]
3737
DistMesh2D = ["DelaunayTriangulation"]
3838

3939
[compat]
@@ -45,7 +45,7 @@ DocStringExtensions = "0.9.3"
4545
DynamicalSystemsBase = "3.13"
4646
Format = "1"
4747
Interpolations = "0.15.1"
48-
IntervalArithmetic = "0.20"
48+
IntervalArithmetic = "0.22"
4949
LinearSolve = "2.37.0, 3"
5050
Optimization = "4"
5151
OptimizationOptimisers = "0.3"

docs/make.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ makedocs(;
4848
modules=[
4949
CriticalTransitions,
5050
Base.get_extension(CriticalTransitions, :ChaosToolsExt),
51-
Base.get_extension(CriticalTransitions, :CoupledSDEsBasin),
51+
Base.get_extension(CriticalTransitions, :AttractorsExt),
5252
Base.get_extension(DynamicalSystemsBase, :StochasticSystemsBase),
5353
# DynamicalSystemsBase
5454
],

docs/src/examples/gMAM_Maierstein.md

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -127,24 +127,6 @@ lines!(ax2, reduce(hcat, tr), linewidth=1, color=(:black, 0.2))
127127
fig
128128
```
129129

130-
## Basins of attraction
131-
132-
Basins of attraction are the regions in the state space that lead to a particular attractor. We can find the basins of attraction using the function `basins`.
133-
134-
```@example GMAM
135-
using Attractors
136-
137-
ba = basins(sys, [0.0, 0], [0.0, 1], [1.0, 0], intervals_to_box([-2, -2], [2, 2]), bstep=[0.01, 0.01], ϵ_mapper=0.001, Ttr=100)
138-
Ur, Vr, atr, M = ba
139-
heatmap(Ur, Vr, M)
140-
```
141-
142-
The basin boundaries can be quickly extracted using the function `basin_boundaries`.
143-
144-
```@example GMAM
145-
bb = basinboundary(ba)
146-
```
147-
148130
## Transitions
149131

150132
We can quickly find a path which computes a transition from one attractor to another using the function `transition.

docs/src/man/systemanalysis.md

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,4 @@ introduced by [Battelino et al. (1988)](https://doi.org/10.1016/0167-2789(88)900
1515
```@docs
1616
edgetracking
1717
bisect_to_edge
18-
```
19-
20-
## Baisin of attraction
21-
```@docs
22-
basinboundary
23-
basboundary
24-
basins
2518
```

docs/src/man/utils.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44

55
```@docs
66
solver
7+
drift
8+
div_drift
79
StochasticSystemsBase.covariance_matrix
810
StochasticSystemsBase.diffusion_matrix
911
noise_process
10-
drift
11-
div_drift
1212
```
1313

1414
## More
1515

1616
```@docs
17-
intervals_to_box
17+
CriticalTransitions.intervals_to_box
1818
```

ext/AttractorsExt.jl

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
module AttractorsExt
2+
3+
using CriticalTransitions
4+
using Attractors: Attractors, AttractorsViaProximity, AttractorMapper
5+
import Attractors: edgetracking, bisect_to_edge
6+
using DynamicalSystemsBase: ParallelDynamicalSystem
7+
8+
export edgetracking, bisect_to_edge
9+
10+
"""
11+
edgetracking(ds::CoupledSDEs, attractors::Dict; diffeq, kwars...)
12+
13+
Runs the edge tracking algorithm for the deterministic part of the CoupledSDEs `ds`.
14+
15+
## Keyword arguments
16+
- `diffeq=(;alg = Vern9(), reltol=1e-11)`: ODE solver settings
17+
- `kwargs...`: all keyword arguments of `Attractors.edgetracking`
18+
"""
19+
function edgetracking(
20+
ds::CoupledSDEs, attractors::Dict; diffeq=(; alg=Vern9(), reltol=1e-11), kwargs...
21+
)
22+
return Attractors.edgetracking(CoupledODEs(ds; diffeq), attractors; kwargs...)
23+
end
24+
25+
"""
26+
bisect_to_edge(ds::CoupledSDEs, attractors::Dict;
27+
u1, u2, bisect_thresh, diffeq, verbose, kwargs...)
28+
29+
Runs the `bisect_to_edge` function for the deterministic part of the CoupledSDEs `ds`.
30+
31+
## Keyword arguments
32+
- `u1`: State 1 (default: first state in `attractors`)
33+
- `u2`: State 2 (default: second state in `attractors`)
34+
- `bisect_thresh=1e-6`: distance threshold
35+
- `diffeq=(;alg = Vern9(), reltol=1e-11)`: ODE solver settings
36+
- `verbose=false`: Verbosity of output
37+
- `ϵ_mapper=nothing`: ϵ argument of `Attractors.AttractorsViaProximity`
38+
- `kwargs...`: Keyword arguments passed to `Attractors.AttractorsViaProximity`
39+
"""
40+
function bisect_to_edge(
41+
ds::CoupledSDEs,
42+
attractors::Dict;
43+
u1=collect(values(attractors))[1][1],
44+
u2=collect(values(attractors))[2][1],
45+
bisect_thresh=1e-6,
46+
diffeq=(; alg=Vern9(), reltol=1e-11),
47+
ϵ_mapper=nothing,
48+
verbose=false,
49+
kwargs...,
50+
)
51+
odes = CoupledODEs(ds; diffeq)
52+
pds = Attractors.ParallelDynamicalSystem(odes, [u1, u2])
53+
mapper = Attractors.AttractorsViaProximity(odes, attractors, ϵ_mapper; kwargs...)
54+
55+
return Attractors.bisect_to_edge(pds, mapper; bisect_thresh, verbose)
56+
end
57+
58+
end # module AttractorsExt

ext/ChaosToolsExt.jl

Lines changed: 3 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,10 @@ Generates a box from specifying the interval limits in each dimension.
2020
"""
2121
function CriticalTransitions.intervals_to_box(bmin::Vector, bmax::Vector)
2222
# Generates a box from specifying the interval limits
23-
intervals = []
24-
dim = length(bmin)
25-
for i in 1:dim
26-
push!(intervals, interval(bmin[i], bmax[i]))
23+
if length(bmin) != length(bmax)
24+
@warn "bmin and bmax must have the same length."
2725
end
28-
box = intervals[1]
29-
for i in 2:dim
30-
box = IntervalArithmetic.cross(box, intervals[i])
31-
end
32-
return box
26+
return SVector{length(bmin)}([interval(bmin[i], bmax[i]) for i in 1:length(bmin)])
3327
end
3428

3529
"""
@@ -65,49 +59,4 @@ function ChaosTools.fixedpoints(sys::CoupledSDEs, box)
6559
return fixedpoints(CoupledODEs(sys), box, jacobian(ds))
6660
end
6761

68-
# function saddles_idx(fps::Tuple)
69-
# num = size(fps[1],1); # number of fixed points
70-
# dim = size(fps[1],2); # dimension of the system
71-
# eigenvalues = fps[2];
72-
# idx = [false for i ∈ 1:num];
73-
# for ii ∈ 1:num
74-
# imag_parts = [imag(eigenvalues[ii][jj]) for jj ∈ 1:dim]
75-
# if all(imag_parts.==0) # we have purely real eigenvalues
76-
# real_parts = [real(eigenvalues[ii][jj]) for jj ∈ 1:dim];
77-
# if prod(real_parts) < 0 # we have at least positive eigenvalue and at least one negative eigenvalue
78-
# idx[ii] = true;
79-
# end
80-
# end
81-
# end
82-
# idx
83-
# end
84-
85-
# function repellers_idx(fps::Tuple)
86-
# num = size(fps[1],1); # number of fixed points
87-
# dim = size(fps[1],2); # dimension of the system
88-
# eigenvalues = fps[2];
89-
# idx = [false for i ∈ 1:num];
90-
# for ii ∈ 1:num
91-
# real_parts = [real(eigenvalues[ii][jj]) for jj ∈ 1:dim];
92-
# if all(real_parts .> 0)
93-
# idx[ii] = true;
94-
# end
95-
# end
96-
# idx
97-
# end
98-
99-
# function attractors_idx(fps::Tuple)
100-
# num = size(fps[1],1); # number of fixed points
101-
# dim = size(fps[1],2); # dimension of the system
102-
# eigenvalues = fps[2];
103-
# idx = [false for i ∈ 1:num];
104-
# for ii ∈ 1:num
105-
# real_parts = [real(eigenvalues[ii][jj]) for jj ∈ 1:dim];
106-
# if all(real_parts .< 0)
107-
# idx[ii] = true;
108-
# end
109-
# end
110-
# idx
111-
# end
112-
11362
end

ext/CoupledSDEsBasin.jl

Lines changed: 0 additions & 19 deletions
This file was deleted.

ext/basin/basinboundary.jl

Lines changed: 0 additions & 95 deletions
This file was deleted.

ext/basin/basinsofattraction.jl

Lines changed: 0 additions & 58 deletions
This file was deleted.

0 commit comments

Comments
 (0)