# What does the Neighbor command do in LAMMPS?

I frequently see LAMMPS codes, and almost all of them have the neighbor 0.5 bin command. I completely studied the LAMMPS manual for the neighbour command and did not understand anything regarding this command.
Could anyone help with these questions below?

• What is the basic purpose of this command?
• What is a Neighbor list and why is it important?

Matter Modeling Asked on December 22, 2021

Neighbour lists are not just a feature of LAMMPS, but of just about any MD engine out there. When you are evaluating your energy function, it is extremely common to have some sort of cutoff for the short-range forces, so that you reduce the complexity of their evaluation from e.g. $$O(N^2)$$ to $$O(N)$$. However, simply checking whether two atoms are within a cutoff distance is also an $$O(N^2)$$ operation, so it's not something you want to do at each timestep. Here's where neighbour lists come to the rescue: you build a list containing each particle's neighbours within a cutoff $$r_n$$, which means that as long as you are sure the particles haven't moved a distance greater than $$r_n-r_{cut}$$ ($$r_{cut}$$ is the force evaluation cutoff), you only need to check the force interactions in that neighbour list, which is a massive upgrade from having to check all interactions!

And here's the catch: if your $$r_n-r_{cut}$$ (also called a "skin" region, your first argument) is large, you will need to build the neighbour list less frequently, but you will need to check more force interactions within each neighbour list. This means that there will be an optimal value of the skin region for achieving maximum computational efficiency but it will unfortunately be system-specific and in some systems even coordinate-specific (e.g. if some parts of your system diffuse faster, they will require faster updates). This is difficult to know a priori, so you either have to guess a good value beforehand, or even spend some time optimising it by hand for a typical system of yours, so that you use that hand-tuned value for all subsequent simulations.

The second argument is, as far as I understand, related to the building of the neighbour list itself. Naively building a neighbour list from scratch is also an $$O(N^2)$$ operation (Verlet list), but you can do a similar trick and create something like a "neighbour list of neighbour lists", i.e. you partition your box into regions, each roughly as big as one neighbour list region, and bin each particle (an $$O(N)$$ operation) to each cell region. After a neighbour list update is triggered, you only need to consider particles from the cell regions immediately surrounding your current one in order to do this, so this is also an $$O(N)$$ operation. This whole method is called a cell list and is usually the preferred way to update a neighbour list. This is what I think the second parameter ("style") does $$-$$ I imagine "bin" value stands for a cell list update, while the "nsq" value stands for a naive $$O(N^2)$$ update.

Answered by Godzilla on December 22, 2021

## Related Questions

### Supercell band structure unfolding advantages

2  Asked on December 23, 2020 by tristan-maxson

### How do I predict the structure of a nanoparticle with Calypso and Quantum ESPRESSO?

0  Asked on December 11, 2020

### How many GB of RAM would be needed for VASP to evaluate optical properties of a material?

1  Asked on December 5, 2020 by anibal-bezerra

### Promising functionals for transition metal chemistry

0  Asked on October 21, 2020 by andrew-rosen

### Atom legend in VESTA

1  Asked on September 26, 2020 by achintha-ihalage

### Weyl Semimetal and Dirac semimetal

1  Asked on August 19, 2020 by shahid-sattar

### Great computer graphics for matter modelling

1  Asked on August 11, 2020 by user14717

### I wrote a Python code to do MD for a Lennard-Jones fluid but the VACF is wrong: What might be the problem?

0  Asked on July 22, 2020 by user207526