Closed TorkelE closed 3 years ago
Hi,
Thank you for trying hard! I appreciate it.
Before I answer all the comments: bifurcationdiagram
will give you nothing for your diagram. Your diagram is too simple... bifurcationdiagram
allows you to branch recursively at stationary bifurcation points (e.g. not Hopf points) and you dont have any. In this case, you are better off using deflated continuation with detection of bifurcation points (see other issue you posted on).
My error messages are much cleaner (I am on master):
────────────────────────────────────────────────────────────────────────────────
--> New branch level = 2, dim(Kernel) = 1, code = 0, from bp #1 at p = 9.063030706988087
- # 1, bp at p ≈ +9.06303071 ∈ (+9.05981691, +9.06303071), |δp|=3e-03, [converged], δ = ( 1, 0), step = 358, eigenelements in eig[359], ind_ev = 1
┌ Error: It seems the point is a Saddle-Node bifurcation. The normal form is (a = 0.0018436142964569494, b1 = 0.015793706727377507, b2 = 0.3066201972182164, b3 = 0.41398034761966024).
└ @ BifurcationKit ~/work/prog_gd/julia/dev/dev1/BifurcationKit/src/NormalForms.jl:203
────────────────────────────────────────────────────────────────────────────────
--> New branch level = 2, dim(Kernel) = 1, code = 0, from bp #2 at p = 4.228100778475947
- # 2, bp at p ≈ +4.22810078 ∈ (+4.22810078, +4.22810078), |δp|=3e-12, [converged], δ = ( 1, 0), step = 568, eigenelements in eig[569], ind_ev = 2
┌ Error: It seems the point is a Saddle-Node bifurcation. The normal form is (a = -0.007753919955655971, b1 = -0.002178682035144704, b2 = 0.0016086450861372025, b3 = -0.00015770032398444782).
└ @ BifurcationKit ~/work/prog_gd/julia/dev/dev1/BifurcationKit/src/NormalForms.jl:203
────────────────────────────────────────────────────────────────────────────────
--> New branch level = 2, dim(Kernel) = 2, code = 0, from bp #3 at p = 10.755971961392275
- # 3, hopf at p ≈ +10.75597196 ∈ (+10.75596950, +10.75597196), |δp|=2e-06, [converged], δ = (-2, -2), step = 1412, eigenelements in eig[1413], ind_ev = 2
Basically it is trying to branch from the bifurcation points which are folds or Hopf. It only considers the fold points which are first labelled as regular bifurcation points until it computes the normal form and see they are folds points. It sends an error because sometimes, the normal form is close to a Pitchfork one and I want the user to be able to know. I should probably find another way to tell so that the user can turn it off.
So basically: nothing went wrong!
Here is a very important point concerning plotting. When the bifurcation points are displayed with square, it means they are poorly located ( bisection was not used for those). For the size, you might prefer
plot(diagram, markersize = 3)
if you change the line thickness (e.g. to make it thicker, and easier to see) the difference disappears.
I can add an option to the plotting recipe for that. Super easy.
Typically I use a different colour, or dashed lines, for the unstable states.
I tried before using dashed for unstable but it is too unreliable. See here unless you have a suggestion. As for different colours, it becomes a mess with many branches.
Is there an easy way of doing this?
The plotting recipe is quite simple, see here
Alternatively, is there a way of extracting the separate branches, as divided by the bifurcation points (I only managed to get the full path)?
Well, I never needed it so I did not write it.
Also, the bifurcation diagram labels the bifurcation dots weirdly doesn't look correct, the dots themself are missing in the label (and the dots in the diagram, especially the Hopf one, are very small).
It is because the fold points overlay them. You can do
plot(diagram, markersize = 3, plotfold=false)
Next, a question. It seems to me that I am setting most of the options twice:
I'd say yes. Passing (args...) -> opts_br
should be enough. I could even use dispatch to simply pass opts_br
.
Why are these required here? Would it be possible to do without them (and what would the negatives of that be?).
They are used for the computation of normal forms. No automatic branching without them. You can pass a finitedifferences version in any cases. The most crutial thing is to know the bifurcation point location precisely. For this, you only need to set nInversion
high enough. Then, if you are not super precise on d2F and d3F, it should be able to branch from simple BP (dimKernel = 1) pretty easily.
This is incredibly helpful. I see what you mean fir the more complicated bifurcation diagrams such as in https://rveltz.github.io/BifurcationKit.jl/dev/BifurcationDiagram/ yeah, I can see that that's a different level of stuff. I'll move over to deflated continuations, as you say, that should probably be enough for everything you encounter in biochemistry.
Is there a list of plot options, for when plotting these things, that I haven't found (with stuff like markersize
)? The only real reason I would want to extract separate branches was that that would give me the option of customising the plotting of the branches.
I would use deflated continuation (DC) when possible, it is quite powerful even considering its drawbacks:
Nevertheless, for "small" systems <100, I'd say it is superior to regular continuation.
Is there a list of plot options, for when plotting these things, that I haven't found
Yes, see here. Then, the plotting options are recipes. Hence, you can do plot(br)
but also plot!(br)
or even scatter(br)
. Finally, you can pass all options of Plots.jl (linewidth,markersize...)
I added a keyword argument to plot
to tune the linewidth of the stable / unstable part, see here.
Should we close this?
Got a bit lost over the holidays. Yes, we should.
So, I have been playing around with the
bifurcationdiagram
function. It's really cool! However, there are a few things I do not understand, and a few other things which seem weird, which I have not been able to understand from reading the docs.For a starter, I run this code to generate my bifurcation diagram:
now this generates a set of error messages, which seems very worrying:
However, I am still actually able to plot the diagram, and it looks correct:
Now the first query is what all these error messages are? What went wrong, but in such a way that the plot still turned out fine?
Next, are there options for modifying the plot diagram? The unstable/stable regions are not very easy to distinguish due to the line thickness and if you change the line thickness (e.g. to make it thicker, and easier to see) the difference disappears. Typically I use a different colour, or dashed lines, for the unstable states. Is there an easy way of doing this? Alternatively, is there a way of extracting the separate branches, as divided by the bifurcation points (I only managed to get the full path)?
Also, the bifurcation diagram labels the bifurcation dots weirdly doesn't look correct, the dots themself are missing in the label (and the dots in the diagram, especially the Hopf one, are very small).
Next, a question. It seems to me that I am setting most of the options twice:
Would I always want to do this, or could I go for something simpler?
Finally, when I created diagrams using
continuation
I didn't have to define so many derivatives as here:rather, in those cases, things worked OK with only the Jacobian (which is autogenerated by the
@reaction_network
macro). Why are these required here? Would it be possible to do without them (and what would the negatives of that be?).