JuliaMolSim / AtomsBase.jl

A Julian abstract interface for atomic structures.
https://juliamolsim.github.io/AtomsBase.jl/
MIT License
81 stars 16 forks source link

should there be a `distance` method? #35

Open rkurchin opened 2 years ago

rkurchin commented 2 years ago

I'm imagining a primary syntax something like distance(sys::AbstractSystem, atom_ind_1, atom_ind_2) that would return the distance between two particles in the structure, and maybe also single-index and no-index options that would return distances from one atom to every other one, and a matrix of distances, respectively?

Similarly, should there be a vector version of a similar kind of thing? (i.e. returns the vector in the bounding_box basis rather than just its length)

Personally, I could imagine these having broad enough use (interatomic potentials, geometry optimization, etc.) that it would be worth having, but curious for others' thoughts.

(And of course, as with the beauty of any interface, anyone could dispatch the function on whatever performant method implementation they want)

mfherbst commented 2 years ago

Hmm. I see your point, but I would advise a bit caution, because this could open up the scene towards a whole zoo of potential methods (what about angles, dihedrals, some projections, spectral/bispectral components, etc.) with the associated explosion in complexity.

I don't have a strong objection, but would like to see more demands first. A key question to me is whether this aspect is so computationally critical that it needs to be part of the interface (allowing for specialisation) as opposed to an add-on package working simply with AtomsBase datastructures in a generic way.

rkurchin commented 2 years ago

Yeah, it's a fair point. I suppose I was thinking about it mainly for my own application where I need the distance but not really the other stuff for building graphs, but I see how it might more naturally fit in a separate "helper" package.