Nearest Neighbor Z-Coordinate Separation

Hello LAMMPS users,

I want to obtain a global vector, "delta_z" of length N (where N is the number of atoms in the system), in which each element, "delta_z_i" is the minimum difference between the z-coordinate of atom i and the z-coordinate of any other atom with a z-coordinate larger than that of atom i (e.g., atom i's "nearest(+z) neighbor"). I can then use fix ave/time to get an averaged distribution of delta_z. I do not want to include second-, third-, etc. nearest(+z) neighbors.

My motivation is the following: I am studying adsorbates in very small-diameter cylindrical pores, such that atoms cannot pass by another, and I have been instructed to calculate this distribution as one descriptor of the structure of the adsorbate.

Does anyone have a suggestion for how to obtain the vector, delta_z? At present, my thought is to write a compute that searches the neighbor list of each particle to find its nearest-z neighbor and then calculates the difference in z-coordinate to that particle. I would use compute_rdf as a starting point.

Kind regards,

Matt Mansell
PhD Candidate
Dept. of Chemical & Biomolecular Engineering
North Carolina State University

A per-atom compute could certainly calculate and store this +delta value.

Assuming you only intend to look at limited number of neighbor atoms

around each atom. You didn’t really define that aspect clearly.

A compute can generate/use a neighbor list to examine the

coords of only nearby atoms for each atom. See

compute coord/atom as an example. That’s better than

compute rdf, because it outputs per-atom quantitices. Rdf

does not.