# What is the difference between a "periodic image" and a "nearest image" in MD simulation?

As far as I understand -

• In MD, when a particle or coordinate moves beyond one face of the simulation box, it reappears on the opposite face as if the box were replicated infinitely in all directions. Each of these replicated positions is called a periodic image.

Then what is a "nearest image"?

What is the difference between a "periodic image" and a "nearest image" in MD simulation?

Do I need first to obtain a "periodic image" to calculate a "nearest image"?

You can generate a periodic image n times in any direction. In comparison, the nearest image is the one that is calculated as +x or -x in the x-direction, +y or -y in the y-direction and +z or -z in the z-direction for an orthorhombic cell. Usually, when performing some analysis, like hydrogen bonding, you might be interested in two residues at the +x and -x ends of the original simulation box but might interact via the nearest images. In the general case, we have lattice vectors $${\bf L}_{i}$$, which may not be orthogonal. With periodic boundary condition, a particle at $${\bf r}$$ has periodic images at $${\bf r}+n_1{\bf L}_1+n_2{\bf L}_2+n_3{\bf L}_3$$ for $$n_1,n_2,n_3 \in \mathcal{Z}$$.
The nearest image will be the image at the smallest distance, $$\min_i {\bf L}_i$$. If you have a cubic box, $$L_1=L_2=L_3$$ and the particle has 6 nearest images corresponding to $${\bf n}=(0,0,\pm 1)$$, $${\bf n}=(0,\pm 1,0)$$ and $${\bf n}=(\pm 1,0,0)$$.