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

br.specialpoint[n].x different from getSolx(br, br.specialpoint[n].idx) #78

Open
yhchang96 opened this issue Jan 27, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@yhchang96
Copy link

Using the temperature model from the tutorial:

using BifurcationKit, Parameters, Setfield
const BK = BifurcationKit

Nop(x; a = 0.5, b = 0.01) = 1 + (x + a*x^2)/(1 + b*x^2)

function F_chan(x, p)
    α, a, b = p.α, p.a, p.b
    f = similar(x)
    n = length(x)
    f[1] = x[1] - b
    f[n] = x[n] - b
    for i=2:n-1
        f[i] = (x[i-1] - 2 * x[i] + x[i+1]) * (n-1)^2 + α * Nop(x[i], a=a, b=b)
    end
    return f
end

n = 101
sol0 = [(i-1)*(n-i)/n^2+0.1 for i=1:n]

par = (α = 3.3, a = 0.5, b = 0.01)

prob1 = BifurcationProblem(F_chan, sol0, par, (@lens _.α))

optcont1 = ContinuationPar(dsmin = 0.01, dsmax = 0.1, ds= 0.01, pMin = 0., pMax = 4.2,
    newtonOptions = NewtonPar(maxIter = 10, tol = 1e-9), saveSolEveryStep=1,
    detectEvent=0, detectBifurcation=0)

@time br1 = continuation(prob1, PALC(), optcont1)

I found that the solution x from br1.specialpoint[n].x and that returned from getSolx (or br1.sol[br1.specialpoint[n].idx].x) are different:

idx = br1.specialpoint[1].idx   # idx=15
all(br1.specialpoint[1].x .== getSolx(br1, idx))   # false
all(br1.specialpoint[1].x .== getSolx(br1, idx+1))   # false
all(br1.specialpoint[1].x .== getSolx(br1, idx+2))   # true

Is this intended or a bug? I thought both should be the same.

I also found that sometimes when I try to refine a fold point (using newton or as part of a codim2 continuation), it doesn't converge at the initial guess even though tol remains the same. I'm not sure if this is related to the above mentioned problem or something that is normal.

@rveltz
Copy link
Member

rveltz commented Jan 27, 2023

It should be a bug and I am surprised I did not put a test for this.

Concerning Fold continuation, the best is to use startWithEigen=true. Open an issue if this does not converge

@rveltz rveltz added the bug Something isn't working label Apr 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants