bifurcationkit / BifurcationKit.jl

A Julia package to perform Bifurcation Analysis
https://bifurcationkit.github.io/BifurcationKitDocs.jl/stable
Other
309 stars 38 forks source link

detectBifucation(state::ContState) always returns false after update v0.1.3 => v0.1.4 #36

Closed gszep closed 3 years ago

gszep commented 3 years ago

This is affecting BifurcationInference.jl is there a new default setting I am not aware of?

rveltz commented 3 years ago

At some point, I removed the computation of eigenvalues from the loop and put it in the iterator, maybe this is it: https://github.com/rveltz/BifurcationKit.jl/commit/cf5870368cc9a3ddc70a76eaea180c930e49d817

Can you display state.n_unstable and see if it is modified?

gszep commented 3 years ago

so its definitely already not working in 0.1.4 so I don't think its the commit you referenced. state.n_unstable along the branch looks like this

(1, 1)
(1, 1)
(1, 1)
(1, 1)
(1, 1)
(1, 1)
(0, 0)
(0, 0)
(0, 0)
(0, 0)
(0, 0)
rveltz commented 3 years ago

I guess you pass the option ContinuationPar.detectBifurcation=3? Where is your iterator loop so I can check it?

gszep commented 3 years ago

ah I pass detectBifurcation=true but passing detectBifurcation=3 doesn't change things. The loop is here https://github.com/gszep/BifurcationInference.jl/blob/036700f1524bcf8832ee9a948ab65e885be00519/src/BifurcationInference.jl#L109

gszep commented 3 years ago

hyperparameters::ContinuationPar is returned by https://github.com/gszep/BifurcationInference.jl/blob/036700f1524bcf8832ee9a948ab65e885be00519/src/Utils.jl#L2

rveltz commented 3 years ago

I think you can remove https://github.com/gszep/BifurcationInference.jl/blob/036700f1524bcf8832ee9a948ab65e885be00519/src/BifurcationInference.jl#L112 as it is in the iterator:

https://github.com/rveltz/BifurcationKit.jl/blob/master/src/Continuation.jl#L351

Then, you need to activate bifurcation detection as:

https://github.com/rveltz/BifurcationKit.jl/blob/master/src/Continuation.jl#L351

Did it really used to work that way?

gszep commented 3 years ago

in v0.1.3 the output of state.n_unstable used to be

(1, 1)
(1, 1)
(1, 1)
(1, 1)
(0, 1)
(0, 0)
(0, 0)
(0, 0)

so I guess the main difference is that there is no longer a transition state (0,1) in the new versions

gszep commented 3 years ago

also note that I have a push!(branch::Branch,state::ContState) method https://github.com/gszep/BifurcationInference.jl/blob/036700f1524bcf8832ee9a948ab65e885be00519/src/Structures.jl#L49

rveltz commented 3 years ago

I think it is because you have https://github.com/gszep/BifurcationInference.jl/blob/036700f1524bcf8832ee9a948ab65e885be00519/src/BifurcationInference.jl#L112

Try to remove it. Whenever you call computeEigenvalues!(iterator,state) it overwrite n_unstable. As I put this call in the iterator in 0.1.4, you call this function twice per continuation step and so bifurcations are undetected

rveltz commented 3 years ago

also note that I have a push!(branch::Branch,state::ContState) method https://github.com/gszep/BifurcationInference.jl/blob/036700f1524bcf8832ee9a948ab65e885be00519/src/Structures.jl#L49

this should not affect the detection

gszep commented 3 years ago

yep that did the trick thanks! I was not aware that computeEigenvalues!(iterator,state) was moved into the iterator (in v0.1.3 if I didn't have it in the loop explicitly it would not record stability info) and the new version makes much more sense 👍🏼

rveltz commented 3 years ago

Yeah, perhaps I should put the bifurcation detection in the iterator as well.