-
-
Notifications
You must be signed in to change notification settings - Fork 81
Update with BifurcationKit #539
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
Conversation
|
(Need to add an updated figure before we can merge) |
|
Could you convert this to be a dynamic tutorial that uses That would cause it to run when docs are built, and let us see immediately if it breaks. (Also, maybe switch to using the preferred u0 / p style with mappings?) |
Sounds good, will do. I could use the mapping notation, however, I would then have to do e.g. |
|
Right, but the point is even using |
|
Going via an |
|
Yeah, that should probably be the way we suggest people get all the "stuff" out they need to interface with non-MT packages. |
|
Looks like there are some issues in running the examples -- the output doesn't look all there: https://catalyst.sciml.ai/previews/PR539/tutorials/bifurcation_diagram/ Have you tried building the docs locally to double check them? |
|
I was unsure how to build them locally (I just ran the code), so I just used the preview function https://catalyst.sciml.ai/previews/PR539/tutorials/bifurcation_diagram/. To me it seems that it is just the display of the actual diagram that fails: The 3 before that doesn't display anything, but given that it would just be an incomprehensible mess, that is probably very much desired... |
|
The final four example boxes have no output, so I think this is an issue. You can build them locally by going into the docs folder, activating the environment there, resolving it, and then including the make.jl file. |
|
Right, BifurcationKit wasn't available for the doc to build. I added it to the docs/Project.toml file. |
|
Ok, some minor thing still needs fixing, will do that when I get home tonight. |
|
Thanks for taking the time to make this dynamic. It will make it much easier to see when package updates, or Catalyst updates, break things going forward! |
|
Think this is done now, unless something happens I'll merge by tomorrow. |
| J = (u,p) -> odefun.jac(u,p,0) | ||
| Next, we specify the system parameters for which we wish to plot the bifurcation diagram. We also set the parameter we wish to vary in our bifurcation diagram, as well as over which interval. Finally, we set which variable we wish to plot the steady state values of in the diagram. | ||
| ```@example ex1 | ||
| p = [:S=>1., :D=>9., :τ=>1000., :v0=>0.01, :v=>2., :K=>20., :n=>3, :d=>0.05] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you make this a Dict then won't your p_bstart calculation become trivial? ModelingToolkit should support Dicts for the mappings too.
|
Just the one comment, maybe make the parameter mapping a dictionary. I think it would simplify the tutorial since it would avoid having to use |
|
Generally I think that would make sense, however, when I do: bprob = BifurcationProblem(F, oprob.u0, oprob.p, (@lens _[findfirst(first.(p).==bif_par)]); recordFromSolution = (x, p) -> x[findfirst(first.(u0).==plot_var)], J=J)I must supply the index of the bifurcation parameter and plotting variable in the resulting array, and I am not sure how to do this robustly, nor if it is even possible. |
|
You can use https://mtk.sciml.ai/dev/basics/FAQ/#Getting-the-index-for-a-symbol to see the recommended way to get a symbolic variable's index. For the species replace |
|
How to I access this function? I got the latest version of MTK, but trying |
|
You have to define that function as in the FAQ. It isn't pre-defined by ModelingToolkit unfortunately. |
|
Ahh, I understand. |
|
Those seems to only work well if you actually have declared the vars/pars as symbolic. After some tinkering the best I got was: indexof(sym,syms) = findfirst(isequal(sym),syms)
par_idx = indexof(:S,Symbol.(ModelingToolkit.parameters(rn)))
var_idx = indexof(:X,Symbol.(getfield.(ModelingToolkit.states(rn),:f)))but I think this will just make things messier than what we already have. |
|
Just |
|
If you want I can update it to handle this part tonight? |
|
That might be better, yeah, I am still unsure exactly how we want this. Loads of thanks! |

This updates the bifurcation diagram tutorial to work with the latest BifurcationKit version. It also uses a slightly less powerful (and thus simpler) approach.