Skip to content

Commit 4ad613c

Browse files
authored
imrpove comparison with BFKit (#169)
1 parent c66b740 commit 4ad613c

File tree

1 file changed

+47
-37
lines changed

1 file changed

+47
-37
lines changed

docs/src/bfkit_comparison.jl

Lines changed: 47 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,10 @@ opts_br = BK.ContinuationPar(
111111
)
112112

113113
# We now create a periodic orbit problem type, by choosing a periodic
114-
# orbit finding algorithm
114+
# orbit finding algorithm. Here we will use an optimized Jacobian
115+
# for a collocation problem (advised via BifurcationKit.jl)
115116

116-
periodic_orbit_algo = BK.PeriodicOrbitOCollProblem(40, 4; meshadapt = true)
117+
periodic_orbit_algo = BK.PeriodicOrbitOCollProblem(40, 4; jacobian = BK.DenseAnalyticalInplace())
117118

118119
# and creating the problem type giving the period guess 19.0
119120

@@ -139,28 +140,37 @@ predictor = BK.PALC(tangent = BK.Bordered())
139140
# and _finally_ call the continuation from BK
140141

141142
@time branch = BK.continuation(probpo, cish, predictor, opts_br;
142-
verbosity = 0, plot = false, argspo...
143+
verbosity = 0, plot = false,
144+
linear_algo = BK.COPBLS(), # faster linear solver
145+
argspo...,
146+
bothside = true,
143147
)
144148

145-
# The code fails to converge. It used to convege in a previous version of BifurcationKit.jl
146-
# but now it doesn't anymore. If it did converge, the following would plot it:
149+
# The converges within about 2 seconds, ignoring compilation time.
150+
# Let's plot the result:
147151

148152
stability = branch.stable
149-
color = [s ? "black" : "red" for s in stability]
150-
marker = [s ? :circle : :x for s in stability]
151-
scatter(branch.branch.p, branch.branch.min; color, marker)
153+
fig, ax = scatter(
154+
branch.branch.p[stability], branch.branch.min[stability];
155+
label = "stable PO", color = "black", marker = :circle
156+
)
157+
scatter!(
158+
branch.branch.p[.!stability], branch.branch.min[.!stability];
159+
label = "unstable PO", color = "red", marker = :x
152160

153-
# The above code takes about 5 seconds to run.
161+
)
162+
axislegend(ax)
163+
fig
154164

155165
# Even the previous version that did work, did not find a
156166
# stable limit cycle for parameter less than 5.0,
157-
# even though we know (see Tutorial) that there is one.
158-
# Or maybe, it is an extremely weakly chaotic attractor with MLE almost 0.
159-
# Or maybe it is a quasiperiodic attractor. One needs to analyze further,
160-
# but Attractors.jl finds everything without much difficulty no matter what.
161-
# Altering the above code to start the continuation at 4.7 finds a limit cycle
162-
# there, but only manages to continue it only up to parameter 4.74,
163-
# instead of well into parameter 5.5 or more that Attractors.jl shows.
167+
# In the main Tutorial we see that there is a limit cycle for
168+
# parameter value down to 4.7. Here we see that the limit cycle is actually
169+
# unstable. So the attractor found in the main Tutorial
170+
# could be a weakly chaotic attractor with MLE almost 0.
171+
# Or maybe it is a quasiperiodic attractor. Or maybe it is an alternative limit cycle
172+
# close to the one tracked here by BifurcationKit.jl.
173+
# One needs to analyze further!
164174

165175
# %% #src
166176

@@ -215,7 +225,7 @@ plot_attractors_curves(
215225
# ## Discussion and comparison
216226

217227
# Attractors.jl found not only a single limit cycle,
218-
# but also all system attractors, including chaotic ones.
228+
# but also all system attractors, including chaotic or quasiperiodic ones.
219229
# It didn't require any initial guess regarding the limit cycle or its period,
220230
# but only a state space box that may contain attractors.
221231
# Attractors.jl is extremely robust w.r.t. to its input parameters:
@@ -228,36 +238,36 @@ plot_attractors_curves(
228238
# And finally, Attractors.jl estimates a more general nonlocal measure of stability,
229239
# in the sense that if a set is nonlocally stable, it is guaranteed to be locally stable,
230240
# however the other way around isn't guaranteed.
231-
# Moreover, due to the orthogonality of finding and matching attractors,
232-
# as well as finding _all_ attractors, the global continuation of Attractors.jl
233-
# can continue along arbitrary user-defined curves in parameter space; not just
234-
# along a single parameter axis. This is possible because it is completely fine
235-
# for some attractors to stop existing during the global continuation,
236-
# while local continuation stops when attractors (and their unstable version)
237-
# stop existing.
238-
239-
# Traditional local continuation can track the unstable
240-
# branches, and automatically detect and label local bifurcations,
241-
# both of which are not possible in Attractors.jl
242-
# (note we didn't bother to plot any of the detected bifurcations - if any are found).
241+
# The global continuation of Attractors.jl continues the whole of a
242+
# multistable state space across an arbitrary parameter curve.
243+
# It finds all attractors that exist at each parameter combination and
244+
# matches them to previous ones to establish continuity.
245+
# It is completely fine
246+
# for some attractors to stop existing during the global continuation.
247+
248+
# Local continuation tracks a single and specific fixed point or limit cycle within a specified
249+
# parameter range. The continuation will stop if the object stops existing all-together.
250+
# But the local continuation can continue to track the object if it becomes unstable.
251+
# Local continuation also automatically detects and labels local bifurcations.
243252
# In our experience having the local bifurcations is always useful.
244-
# Now, whether the unstable branches are of a limit cycle are useful or not,
253+
# Now, whether the unstable branches of a limit cycle are useful or not,
245254
# depends on the research question and whether the analysis is done for some
246255
# sort of real world understanding (unstable limit cycles / fixed points don't
247256
# actually exist in the real world).
248257
# Beyond this however, BifurcationKit.jl is also optimised for PDE systems,
249258
# while Attractors.jl isn't.
250259

251-
# Now, we have to be a bit more transparent here.
252-
# Besides this absence of stable orbits for parameter less than 5.0
253-
# that we discussed in the end of the BifurcationKit.jl version,
254-
# we need to say that it took **a lot of effort** to make the
255-
# BifurcationKit.jl code work. At least, a lot of effort compared with the effort
260+
# To be transparent, the biggest downside of local continuation software
261+
# (and not a particular downside of BifurcationKit.jl specifically),
262+
# is that it can take **a lot of effort** or **a lot of expertise** to make them work.
263+
# At least, a lot of effort compared with the effort
256264
# it took to make the Attractors.jl version work, which was simply "increase the recurrences
257265
# threshold", which is standard practice when dealing with chaotic systems
258266
# [Datseris2022](@cite). For example, any other of the
259-
# periodic orbit algorithms of BifurcationKit.jl (such as shooting or trapezoid) fails.
260-
# Using a slightly incorrect initial period guess of 20.0 instead of 19.0 also fails.
267+
# periodic orbit algorithms of BifurcationKit.jl (such as shooting or trapezoid) fails
268+
# unless its parameters are adjusted. Using alternative specifications for the Jacobian
269+
# or the linear solving algorithm can also lead to failure.
270+
# Using an incorrect initial period guess can also lead to failure.
261271
# We imagine that this sensitivity would apply also to some other of the
262272
# several meta-parameters that enter a traditional continuation routine,
263273
# for example the thresholds and accuracy parameters related to Newton convergence,

0 commit comments

Comments
 (0)