BifurcationKit nd point periodic orbit

Hello, I am new to Julia and BifurcationKit.jl. I would like to simulate a model, 6 differential equations, 4 complex 2 real variables. Because I am new, I started from a simplified version, 2 equations, 2 complex variables. I followed the examples and created following sample code.

using Revise
using Plots
using BifurcationKit
using DifferentialEquations
const BK = BifurcationKit

function ACR!(du, u, p, t = 0)
    r_in,g,l = p
    a1_r, a1_i, a2_r, a2_i = u

    du[1] = real(g*(a1_r+im*a1_i).-im*r_in*(a2_r+im*a2_i))
    du[2] = imag(g*(a1_r+im*a1_i).-im*r_in*(a2_r+im*a2_i))

    du[3] = real(l*(a2_r+im*a2_i).-im*r_in*(a1_r+im*a1_i))
    du[4] = imag(l*(a2_r+im*a2_i).-im*r_in*(a1_r+im*a1_i))

    du
end

par_com = (r_in=0., g=1.0, l=-1.0)

prob = BifurcationProblem(ACR!, [1.0,1.0,1.0,1.0], par_com, (@optic _.r_in); record_from_solution = (x, p; k...) -> (a1_r = x[1], a1_i = x[2], a2_r = x[3], a2_i = x[4]))

p_span = (0.0, 3.0)
opts_br = ContinuationPar(p_min = p_span[1], p_max = p_span[2])

br = continuation(prob, PALC(), opts_br,bothside = true)

scene = plot(br, plotfold=false, markersize=4, legend=:topleft)

function record_from_solution(x, p; kwargs...)
 xtt = get_periodic_orbit(p.prob, x, p.p)
 min, max = extrema(xtt[1,:])
 period = getperiod(p.prob, x, p.p)
    return (; min, max, period)
end

br_po = continuation(br, 2, ContinuationPar(),
        PeriodicOrbitOCollProblem(100, 5);record_from_solution)

I got the following plot and error message

ERROR: The provided index does not refer to a Hopf Point
Stacktrace:
 [1] error(s::String)
   @ Base .\error.jl:35
 [2] hopf_normal_form(prob::BifurcationProblem{…}, br::ContResult{…}, ind_hopf::Int64; nev::Int64, verbose::Bool, lens::PropertyLens{…}, Teigvec::Type, detailed::Bool, autodiff::Bool, scaleζ::typeof(LinearAlgebra.norm))
   @ BifurcationKit \.julia\packages\BifurcationKit\AvmP9\src\NormalForms.jl:953
 [3] hopf_normal_form
   @ \.julia\packages\BifurcationKit\AvmP9\src\NormalForms.jl:942 [inlined]
 [4] continuation(br::ContResult{…}, ind_bif::Int64, _contParams::ContinuationPar{…}, pbPO::PeriodicOrbitOCollProblem{…}; bif_prob::BifurcationProblem{…}, alg::PALC{…}, δp::Nothing, ampfactor::Int64, usedeflation::Bool, detailed::Bool, use_normal_form::Bool, autodiff_nf::Bool, nev::Int64, kwargs::@Kwargs{})
   @ BifurcationKit \.julia\packages\BifurcationKit\AvmP9\src\periodicorbit\PeriodicOrbits.jl:391
 [5] continuation(br::ContResult{…}, ind_bif::Int64, _contParams::ContinuationPar{…}, pbPO::PeriodicOrbitOCollProblem{…})
   @ BifurcationKit \.julia\packages\BifurcationKit\AvmP9\src\periodicorbit\PeriodicOrbits.jl:372
 [6] top-level scope
   @ \coupled_resonators.jl:38
Some type information was truncated. Use `show(err)` to see complete types.

For the parameter r_in>1, I know that there are periodic solutions. How can I show periodic orbits in bifurcation diagram ? Does bifurcation point always have to be hopf ? Thank you.

prob = ODEProblem(ACR!, [1,1,1,1], [0,10], [1.1,1,-1],saveat=[0:0.01:10;])

sol = solve(prob)

a1 = sol[1,:] + im*sol[2,:]
a2 = sol[3,:] + im*sol[4,:]

plot(sol.t,abs2.(a1))
plot!(sol.t,abs2.(a2))
julia> eigenvals(br,13)
4-element Vector{ComplexF64}:
  3.0232587956638806e-17 - 0.04468859264398821im
  3.0232587956638806e-17 + 0.04468859264398821im
 -3.0232587956638806e-17 - 0.04468859264398821im
 -3.0232587956638806e-17 + 0.04468859264398821im

so this is not a Hopf… You must have symmetries.
You cannot branch from this point. Either break the symmetry or continue a periodic orbit from a simulation like in 🟠 Periodic predator-prey model · Bifurcation Analysis in Julia

1 Like

also your system is linear