Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MethodError: objects of type ContinuationPar{Float64, DefaultLS, DefaultEig{typeof(real)}} are not callable #173

Closed
RuqiShi12 opened this issue Sep 3, 2024 · 2 comments

Comments

@RuqiShi12
Copy link

RuqiShi12 commented Sep 3, 2024

Hi, I'm making a bifurcation diagram for my system, following the example document:

using Revise, Plots
using BifurcationKit, Parameters, LinearAlgebra

# Define the function for the state variables
function SB(u, p)
    a₁, a₂ = u  # unpack the state variables (complex numbers)
    δω, U₀ₑ, τ, κ, phi, f = p  # unpack parameters
    d = im * exp(im * phi / 2) / sqrt(τ)
    γ = -1/(2*τ)

    # Compute the derivatives
    [
        (im * (δω + abs2(a₁) / U₀ₑ) - 1) * a₁ + τ * (im * κ + γ) * a₂ + τ * d * f,
        (im * (δω + abs2(a₂) / U₀ₑ) - 1) * a₂ + τ * (im * κ + γ) * a₁ + τ * d * f
    ]
end

function wrap_SB(u, p)
    # Convert real and imaginary parts back to complex numbers
    a₁ = complex(u[1], u[2])
    a₂ = complex(u[3], u[4])
    
    # Apply the original system's function
    out = SB([a₁, a₂], p)  
    
    # Return the real and imaginary parts separately
    return [real(out[1]), imag(out[1]), real(out[2]), imag(out[2])]
end

# Define the parameters
par = (δω = -0.2, U₀ₑ = 1.0, τ = 1.0, κ = 0.8, phi = 0.0, f = sqrt(2.5))

# Define the initial condition for the state variables
u0 = [0.3, 0.0, 0.3, 0.0]

# Define the BifurcationProblem
prob = BifurcationProblem(wrap_SB, u0, par, (@lens _.f);
                          record_from_solution = (u, p) -> (abs2(complex(u[1], u[2])), complex(u[1], u[2])))


# options for newton
# we reduce a bit the tolerances to ease automatic branching
opt_newton = NewtonPar(tol = 1e-9)

# options for continuation
opts_br = ContinuationPar(dsmin = 0.001, dsmax = 0.005, ds = 0.001,
	newton_options = opt_newton,
	nev = 1,
	# parameter interval
	p_min = 1.0, p_max = 2.,
	# detect bifurcations with bisection method
	# we increase here the precision for the detection of
	# bifurcation points
	n_inversion = 8)

diagram = bifurcationdiagram(prob, PALC(),
	# very important parameter. This specifies the maximum amount of recursion
	# when computing the bifurcation diagram. It means we allow computing branches of branches
	# at most in the present case.
	2,
	opts_br,
)

# You can plot the diagram like
plot(diagram; putspecialptlegend=false, markersize=2, plotfold=false, title = "#branches = $(size(diagram))")

However, the output is an error showing:
ERROR: MethodError: objects of type ContinuationPar{Float64, DefaultLS, DefaultEig{typeof(real)}} are not callable

Could you help? Thanks!

@rveltz
Copy link
Member

rveltz commented Sep 3, 2024

Hi,

It looks like it works on [email protected]

@RuqiShi12
Copy link
Author

Hi,

It looks like it works on [email protected]

Thanks, it works after I upgrade the version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants