ACEsuit / ACE.jl

Parameterisation of Equivariant Properties of Particle Systems
65 stars 15 forks source link

Per-atom descriptors #108

Closed exapde closed 2 years ago

exapde commented 2 years ago

Is there a way to obtain per-atom descriptors from ACE.jl? By "per-atom descriptors", I mean the values of the local descriptors at every atom site before summing them up to obtain the global descriptors.

cortner commented 2 years ago

yes that is fairly easy to do, but we don't provide a convenient interface at the moment. If you tell me a little bit what your application is, then I can also suggest whether should use ACE.jl or ACE1.jl which is much better tested and more user-friendly at the moment. I can then also put together a user interface for per-atom descriptors, with your input.

exapde commented 2 years ago

I am interested in comparing ACE potential with SNAP and SOAP for hafnium oxidation. With SNAP, I can get all the descriptors and derivatives. However, I don't know how to obtain the descriptors with ACE.jl, even though I were able to run the example https://acesuit.github.io/ACE1docs.jl/dev/tutorials/developing/. Of course, the descriptors must be computed somewhere in your code. If you can point me where they are computed and how to obtain them, I appreciate your help.

cortner commented 2 years ago

ok, I'll put together a PR for ACE1 asap.

cortner commented 2 years ago

actually looking through the codes we do have it ALMOST implemented:

https://github.com/JuliaMolSim/JuLIP.jl/blob/68e1f987ba7f51fc1145870cbc99b2718da38f1f/src/mlips.jl#L289

(Note that JuLIP provides the energy, forces etc implementations, not only for potentials but also for an abstract basis for a linear MLIP. This works not only for ACE but also some variants.)

Once you have an ACE basis basis, say, and an atoms object at you could simply define

site_energies(basis::IPBasis, at::Atoms) = site_energy.(Ref(basis), Ref(at), 1:length(at))
site_energies_d(basis::IPBasis, at::Atoms) = site_energy_d.(Ref(basis), Ref(at), 1:length(at))

or something along those lines. (I didn't test it) The first line would define the per-atom descriptors you want, while the second line would give you the derivatives w.r.t. to the local sites. This might not be a particularly effective data layout since it uses vectors of vectors of vectors .... but it should "just work" and will let you test it at least, and show you how to write a more efficient scheme if you wish. I'm happy to help with that of course.

cortner commented 2 years ago

One important thing to keep in mind here is that we do not yet provide sensible defaults. Probably best to ping myself and @casv2 on ACE-Slack to discuss how to choose the parameters.

cortner commented 2 years ago

Please close this if you are happy with this, otherwise let me know what else you need.

exapde commented 2 years ago

Thank you very much. Your suggestion is very helpful. Just another question: the two functions

function energy(shipB::IPBasis, at::AbstractAtoms{T}) function forces(shipB::IPBasis, at::AbstractAtoms{T}) where {T}

compute the descriptors and their derivatives for all atoms in the at struct?

cortner commented 2 years ago

yes and then sum them up. That's the definition of total energy. forces are analogous.

If you want a partial energy (i.e. sum over a subset) we could very easily add this to JuLIP.jl

exapde commented 2 years ago

You are great help! I'll keep you posted about my experiences/any results with ACE.

cortner commented 2 years ago

looking forward to hearing it!