Page 1 of 1

computeNeighborListVoxelHash

Posted: Thu Feb 25, 2021 7:57 am
by sam
Guys,

I am using computeNeighborListVoxelHash to find all the neighbors of a list of specific atoms, in the system. Basically I want to specify a short stretch of viral DNA, and find all atoms (in this case, other DNA atoms) nearby.

I am not sure I am using this function in the most efficient way, and can't find any documentation on it. Basically what I do is create a particle list containing all the atoms in my system. Then I use computeNeighborListVoxelHash to find all pairs within a certain radius or each other. Lastly, I loop through this list of pairs, and see if either atom in the pair is one of my specific atoms. If so, then the OTHER atom is added to my list of neighbors. When I am done I have a nice little blobbly bubble of atoms near my DNA stretch of interest. This works fine for most applications. But now I am working on an entire viral genome and it is waaaaay too slow.

Is there a way to get the neighbors of specified atoms more directly? Please

thanks

Sam

Re: computeNeighborListVoxelHash

Posted: Fri Feb 26, 2021 10:55 am
by peastman
The first thing to remember is that computeNeighborListVoxelHash() is part of the Reference platform. So it's really slow! It doesn't attempt any significant optimizations. The CPU platform has a CpuNeighborList class which is much faster (multithreaded, vectorized, and just generally optimized).

In general, though, this still won't be an optimal approach for your application. If you only need the neighbors of a small group of atoms, why waste time finding the neighbors of other distant atoms? You may find it's best to write your own code for this. A simple but reasonably efficient algorithm would be

- Assign all atoms to voxels.
- Loop over the atoms you're interested in.
- For each one, loop over the 3x3x3 cube of voxels surrounding it.
- Loop over the atoms in each voxel and compute the distance.