Issues with continuation in BifurcationKit

Hi!

I am new to Julia and BifurcationKit. I am trying to perform a bifurcation analysis of the Jansen-Rit model as was done by Grimbert and Faugueras but I keep running into this error when calling continuation

The function iterate_from_two_points exists, but no method is defined for this combination of argument types.
Closest candidates are:
  iterate_from_two_points(::ContIterable, ::Any, ::T, ::Any, !Matched::T; _verbosity) where T
   @ BifurcationKit ~/.julia/packages/BifurcationKit/RaJtn/src/Continuation.jl:382

I have tried some of the tutorials on the BifurcationKit website, but this steps works fine. I am using Jupyter Notebook in VSCode if it makes a difference. If someone could provide some guidance I would greatly appreciate it!

Here is the full code:

using Revise, Plots
using BifurcationKit

const BK = BifurcationKit

# Define the function σ
function σ(v, e0 = 2.5, v0 = 6, r=0.56)
    2 * e0 / (1 + exp(r * (v0 - v)))
end

# vector field
function jansenrit(z, param)
	(;A, a, B, b, C1, C2, C3, C4, p) = param
	y0, y3, y1, y4, y2, y5 = z
	[
	    y3
        A * a * σ(y1 - y2) - 2 * a * y3 - a^2 * y0
        y4
        A * a * (p + C2 * σ(C1 * y0)) - 2 * a * y4 - a^2 * y1
        y5
        B * b * C4 * σ(C3 * y0) - 2 * b * y5 - b^2 * y2
	]
end

# parameter values
C= 135
par = (A = 3.25, a = 100, B = 22, b = 50, C1 = C, C2 = 0.8 * C, C3 = 0.25 * C, C4 = 0.25 * C, p = 50)

# initial condition
z0 = [0.0, 0.0, 15.0, 0.0, 10.0, 0.0]

# Bifurcation Problem
prob = BifurcationProblem(jansenrit, z0, par, (@optic _.p);
	record_from_solution = (x, p; k...) -> (y0 = x[1], y3 = x[2], y1 = x[3], y4 = x[4], y2 = x[5], y5 = x[6]),)

opts_br = ContinuationPar(p_min =1.0, p_max = 400.0)

# continuation options, we limit the parameter range for p
opts_br = ContinuationPar(p_min =1.0, p_max = 400.0)

# continuation of equilibria
br = continuation(prob, PALC(), opts_br;
	# we want to compute both sides of the branch of the initial
	# value of p = 100
	bothside = false, verbosity = 3)

it is because par.p is an Int. Use par = (A = 3.25, a = 100, B = 22, b = 50, C1 = C, C2 = 0.8 * C, C3 = 0.25 * C, C4 = 0.25 * C, p = 50.0)

1 Like

Thank you Romain! Now I am confused about how to set the range for p. Even though I have set p_min =0.0 and p_max =400.0, it only goes from 50 to ~110. I assume the 50 comes from the initial parameter values set in ‘par’. I have tried different settings for dsmax, ds_min, ds but I can only increase the range so much.

# continuation options, we limit the parameter range for p
opts_br = ContinuationPar(p_min =0.0, p_max = 400.0, dsmax = 2.0, dsmin= 0.001, ds = 0.001, max_steps = 1000)

# continuation of equilibria
br = continuation(prob, PALC(), opts_br;
	# we want to compute both sides of the branch of the initial
	# value of p = 100
	bothside = false, verbosity = 3)

br does not contain 1000 points? What is the last continuation step printed in the REPL?

No, it only had 308 points. I managed to fix it though by lowering the Newton tolerance to e-9. Now I am able to get to the max_steps I specify.

Do you think it might have been failing to converge before? It wasn’t logging anything apart from a “5-element Vector{ComplexF64}” (I don’t know what this vector is) so it is difficult to say what was happening.

You can tell this by passing NewtonPar(verbose = true). You can also use the normC = norminf instead of the 2-norm. Please tell us if this is newton tolerance that was too small.

Is doing normC = norminf equivalent to passing NewtonPar(verbose = true)? The outputs seems slightly different, but it does seem like tolerance is the issue

With normC = norminf:

And with NewtonPar(verbose = true):

Hi

No NewtonPar contains the newton parameters. Above you just specify that you want newton to output it’s iterations.

But judging from your screenshots, you don’t see them. Are you using Pluto.jl?

basically, I was suggesting to do


br = continuation(prob, PALC(), ContinuationPar(opts_br, newton_options = NewtonPar(tol = 1e-11, verbose = true));
	# we want to compute both sides of the branch of the initial
	# value of p = 100
        normC = norminf,
	bothside = false, verbosity = 3)

Hey!

The iterations get printed but not always, perhaps because I am using a Jupyter Notebook.

Do you recommend Pluto?

Ah that’s why. I use vscode where all iterations are printed.

I do not use pluto