More Efficient Way of Computing Neighbors in Range

Click For Summary

Discussion Overview

The discussion revolves around optimizing the computation of neighboring atoms in a 3D space simulation, specifically focusing on the use of MATLAB's rangesearch function and alternative methods for determining atomic bonds during simulation steps.

Discussion Character

  • Exploratory
  • Technical explanation
  • Debate/contested

Main Points Raised

  • One participant inquires about the possibility of reusing previously computed pairs of neighboring atoms to enhance computational efficiency in subsequent simulation steps.
  • Another participant argues against the feasibility of reusing pairs, suggesting that a standard approach involves dividing the simulation box into smaller regions and conducting searches within those regions, while also checking neighboring regions for border cases.
  • A participant mentions that rangesearch utilizes a kd-tree algorithm, which they do not fully understand but believe operates similarly to the proposed standard method.
  • One participant shares their experience using LAMMPS for simulations and notes that the create_bonds command likely reruns calculations at each step, implying a similar approach to rangesearch.
  • Another participant reflects on their own experience with a graphene system, where they developed a custom solution in Python that efficiently calculated bonds by selecting small regions slightly larger than the expected bond length.

Areas of Agreement / Disagreement

Participants express differing views on the efficiency of reusing previously computed pairs, with some advocating for standard region-based searching methods while others explore the potential of existing tools like rangesearch and LAMMPS. The discussion remains unresolved regarding the best approach to optimize neighbor computations.

Contextual Notes

Participants highlight limitations in their understanding of the kd-tree algorithm and the specifics of the rangesearch function, indicating a reliance on definitions and assumptions that may not be fully clarified.

person123
Messages
326
Reaction score
52
TL;DR
I'm using searchrange to locate all pairs of points within a range of one another. This is done for each step of a simulation; points move gradually from one to the next. Could I use the neighbors from the previous step to speed up computation?
Hi. I have a collection of points in 3D space. I'm using MATLAB to find all pairs of points within a certain range from one another. Right now I'm using rangesearch(X,X,r), where X is the collection of points and r is the range.

These points are the locations of atoms and I am attempting to determine atomic bonds. I am doing this for every step in a simulation. Most bonds do not change from one step to the next. Would I be able to use the pairs computed from the previous step to speed up computation for the next, as opposed to rerunning rangesearch each time? Thanks.
 
Physics news on Phys.org
person123 said:
Would I be able to use the pairs computed from the previous step to speed up computation for the next,

I don't think so.

I am not sure what "rangesearch" does exactly but never try to compute every atom with every other atom in the simulation box. The standard way of computing a "neighbouring map" is to divide your simulation box into small regions and do a search in each small region (and also cross check with the neighbouring regions for the ones on the border.) You have to do that in each step though since atoms might be getting closer or away from each other.

You might also want to check some advanced MD simulator like LAMMPS (it is open code) to see if they implemented a clever solution using the previous step. (I doubt so though...)
 
hacivat said:
I am not sure what "rangesearch" does exactly but never try to compute every atom with every other atom in the simulation box. The standard way of computing a "neighbouring map" is to divide your simulation box into small regions and do a search in each small region (and also cross check with the neighbouring regions for the ones on the border.)
rangesearch uses a kd-tree algorithm, which I don't fully understand, but I think works similar to the standard way you're describing.

hacivat said:
You might also want to check some advanced MD simulator like LAMMPS (it is open code) to see if they implemented a clever solution using the previous step. (I doubt so though...)
I'm actually using LAMMPS to run the simulation then analyzing the CFG files (they give me the atom coordinates at each frame) in MATLAB. I think the create_bonds command in LAMMPS does something similar. It seems to me like you would also rerun it each step and I assume it uses a similar approach.
 
person123 said:
rangesearch uses a kd-tree algorithm
OK, just looked at the wikipedia page, that seems like an advanced thing. I doubt you will find something better. (I once had a graphene system with 5000 atoms and had to get the bonds, didn't know that algorithm, wrote my own code in python with the method I described, it was very quick in calculating actually. I only needed it once though.) The trick is to select the small regions like 2 - 2,5 Angstrom side cubes. Only slightly bigger than your expected bond length and also check with the neighbouring regions.
 

Similar threads

Replies
7
Views
2K
  • · Replies 18 ·
Replies
18
Views
2K
  • · Replies 4 ·
Replies
4
Views
6K
Replies
2
Views
3K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 0 ·
Replies
0
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K