-
Notifications
You must be signed in to change notification settings - Fork 40
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
Disable AD for Continuation #196
Comments
Hi,
Thank you for pointing this. The issue is based on an older version of BK so that's why the name difference. Where do you see this in the docs? |
Yes, contrary to Auto and Matcont, BK uses the Hopf normal form to have a robust branch switching from a simple Hopf point. That answers your point 1. I could try to add a Basic branch switching ala Auto but that will take some time. |
For the other derivatives, you can perhaps use https://github.com/JuliaDiff/FiniteDifferences.jl Otherwise, this could work (not tested)
|
I saw it in the doc string of |
Thanks for your suggestions. I did a bit of testing with the problem outlined in https://bifurcationkit.github.io/BifurcationKitDocs.jl/stable/tutorials/ode/tutorialsODE/#nmepo
Somewhat unsurprisingly, the results are highly dependent on AD
FD
And I can get somewhere close with Periodic orbit simulations. I'm sure I could get closer with a bit more fiddling (e.g., higher-accuracy finite difference schemes / tweaking continuation parameters), and perhaps I chose a poor model to try this on. But in general, I wouldn't call the process robust. Overall, I think my conclusion is that if the code is not suitable for AD, stick to other tools with less reliance on the higher-order derivatives (you wouldn't know of an AUTO julia wrapper would you? :) ). However, I shall continue to explore using BifurcationKit for code written purely in Julia. Cheers for your help, |
Hi, You probably need to scale Once the initial guess is computed, the code is pretty similar to Auto and Matcont.
For your plot, I am surprised. The Floquet coefficients should only derail on the way to the homoclinic point. You may be using an old version of the code. I will add a backend for full FD when I have some time |
Ah ok, perhaps I should hold back on making any judgement yet.
I'm using version 0.4.6, which I think is the latest release.
I'll be interested in trying these updates in the future. My current research goal is to run continuation on higher-dimensional aeroelastic models, which may not always play nicely with AD... This wasn't a rabbit hole I thought I would go down (this was meant to be an easy first problem), but it's been a good learning exercise for Julia. If it's of any use as a test case, my adaptation of the example is below. The 2nd order derivative uses For a nominal test case, the finite difference at
but the PO continuation currently fails when compared to the AD solution Once again, cheers for your active communication!
|
It is very difficult to write code that has no bug in particular when computing the normal forms. Using AD removes a lot of difficulties but now that it has settled I should relax that need. In BK you really only need higher order derivatives to compute predictors for branch switching. But I will soon allow to use a very simple predictor (ala Auto - Matcont) Now for your high dimensional aeroelastic models, you will be able to do the same as the TMModel but with Jacobian-Free methods (which are not in Auto or MatCont). |
No problem. Your example shows me that my treatment of stability of the periodic orbits may be too simple. Maybe Auto or Matcont is doing something clever with the Floquet coefficients. In your plot, you see a lot of spurious bifurcations. This is because the trivial multiplier I should note that the (numerical) value of the Floquet coeffs is the same as Auto's or Matcont's. |
Ah, interesting. I've not used Jacobian free methods before, so I'll definitely give them a go at some point!
I'm not 100% sure I'm in the right part of the source code, but I wouldn't call it clever. it seems to be floq < 1+tol https://github.com/auto-07p/auto-07p/blob/8b6cf/src/periodic.f90#L2029-L2039 There's also a bit of a discussion in the floquet multiplier section about methods to minimise roundoff errors https://github.com/auto-07p/auto-07p/blob/beb2fb79c9bb/src/floquet.f90#L144-L167 |
Is it possible to disable automatic differentiation and use finite difference for the calculation of period orbits and normal forms?
I am just starting with Julia and BifurcationKit and as a first step I was trying to replicate results I have generated using AUTO in another programming language. To do this, I wrapped an external call to a function in a different langauge
derivfunc
is not suitable for Automatic differentiation and as such the inputs of the function can only be vectors of real numbers. ( I know this is a slightly contrived example, but the generalised case where automatic differentiation cannot be used in the call to the derivative function seems generic enough)In terms of the continuation of equilibria, my question is related to #68 . By setting the
J = (x,p)->BifurcationKit.finite_differences(z->derivfunc(z,p), x))
in theBifurcationProblem
I was able to solve for equilibrium positions. (I have a quick side note here: both #68 and the documentation forBifurcationProblem
suggest usingBifurcationKit.finiteDifferences
. I guess the naming was changed at some point, but the doc string wasn't updated?)However, I cannot solve for periodic orbits (the continuation of a simple Hopf). Regardless of which method I pick the code will always error on line 243 of Problems.jl
e.g. it still attempts to calculate the second (and third) derivatives using automatic differentiation. I first tried to 'cheat' this by making d2F not
nothing
, e.g. (d2F = (x,p,dx1,dx2)->throw(DomainError("Second derivatives not implemented"))
) but alas, all the periodic methods I tried require the calculation of d2F. Additionally, I would like to estimate the normal form, which also requires the derivatives.So my questions:
Thank you for any help you can provide.
Cheers,
Fintan
The text was updated successfully, but these errors were encountered: