-
Notifications
You must be signed in to change notification settings - Fork 23
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
Support for symbolic variable type ::Num
?
#175
Comments
JuLIP is quite old and possibly not flexible enough to easily adapt to abstract number types. E.g. I've long wanted to allow dual and hyer-dual numbers. Those would give you the same I think. I was planning to re-work Stillinger-Weber and EAM to allow this, but within the new |
Sounds good, I will keep an eye on |
that's the goal |
If you look at EmpiricalPotentials now, the SW potential can already accept general number types as inputs. |
I had a look and indeed types are no longer the problem, but, as expected, conditional statements involving cut-offs are. Here is a MWE, adapted from the tests in EmpiricalPotentials:
Then we get an error
and the responsible line is
When I remove the conditional statements in the definition of
The output for But the bottom line is, it is super quick and works (at least in principle), provided that we ensure no conditional statements are supplied :) |
We could remove the cutoff check by multiplying with a characteristic function that could then be overloaded for your number type. In principle I'm open to this, but I suspect this won't go well for more general potentials especially of ACE-like complexity ... Have you considered symbolic regression instead? |
Hi Christoph, together with @Fraser-Birks and @jjbraun we are looking at trying to implement the$\mathcal{O}(r^{-1})$ boundary conditions for Mode I fracture and we believe that we can derive an explicit form for it for a general anisotropic case. This is somewhat optimistic at this stage, but provided that we can do it, then to assemble such a boundary condition, a user would need to supply 2nd order and 3rd order elastic constants. It would be beautiful to just be able to compute them automatically for a given interatomic potential and so really a user gets it "for free". We are playing around with the idea of doing it symbolically, since these days
Symbolics.jl
seems to work surprisingly well on code that was not developed with symbolic variables in mind.So I gave it a go with JuLIP, as follows:
This errors of course, we get
And I initially thought that it might to with the fact that
::Num
is not compatible withStaticArrays.jl
, but I can runand it works. So I also tried
but it results in the same error. I think the problem is simply that
Atoms
requires a type input which is a subtype ofAbstractFloat
butNum
is not that.However, if I just take bits of codes from JuLIP for computing energies for pair potentials, then everything works rather well:
and it gives us what we want and very quickly too!
I think with some effort, this should also work for n-body interactions, especially say with ACE potentials. I would be very happy to try to code it up, but I was wondering if you had some input whether trying to include support for
::Num
is feasible? I can envision quite a lot of issues with cut-offs, either because we add awful lot of extra terms in symbolic differentiations and also as symbolic variables usually don't work too well if we have some conditional statement, which we might with cut-offs?The text was updated successfully, but these errors were encountered: