Open ryangmullen opened 3 years ago
Did you find that this actually caused a problem for you when using Cassandra?
Dr. Toon Verstraelen discussed this in this thread on stackexchange, and noted that despite this minimum image distance algorithm being naive, it still works without causing problems as long as the maximum interaction distance cutoff is "shorter than half the shortest distance between the opposite faces of the unit cell," citing this note by B. Smith that explains it. On page 6, the note mentions, "the procedure is safe if one is using a spherical cutoff in R space, the radius of which is not greater than half the smallest perpendicular width of the MD cell."
Cassandra requires that the interaction cutoff distance be no more than half the shortest distance between opposite faces of the simulation box, so its naive algorithm shouldn't be problematic. In your example, this value is 0.4330125, and the minimum image distance in your example is 0.505181, so these atoms wouldn't interact anyway.
Expected behavior
The subroutine Minimum_Image_Separation should compute the minimum image distance between two atoms.
Current behavior
The subroutine Minimum_Image_Separation computes the distance from a central atom i to the image of another atom j in a cell centered on atom i. For cubic and orthogonal cells, the distance between atom i and the image of j in this cell will be the minimum image distance. However, for triclinic cells the image j in this cell may not be the closest image to i.
Steps to reproduce
3a. As input, the vector pointing from atom 1 to atom 2 is (13/24, 13/24, 0) in scaled coordinates and (0.812501, 0.469097, 0) in Cartesian coordinates. The length of this vector is 0.938195. 3b. In a triclinic cell centered on atom 1, atom 2 gets wrapped along lattice vectors a and b. The vector pointing from atom 1 to image 2 is (-11/24, -11/24, 0) in scaled coordinates and (-0.687499, -0.396928, 0) in Cartesian coordinates. The length of this vector is 0.793856. This is the distance that CASSANDRA finds. 3c. If we wrap atom 2 only using lattice vector a, the vector pointing from atom 1 to image 2 is (-11/24, 13/24, 0) in scaled coordinates and (-0.187499, 0.469097, 0) in Cartesian coordinates. The length of this vector is 0.505181. This is the distance that CASSANDRA should find.
Possible solution (optional)
Rather than wrapping atoms such that the scaled distance between atoms is on the range [-0.5, 0.5] along each lattice vector, we might could wrap atoms until the Cartesian component of the distance is on the range [-hbox, hbox] where hbox is half the distance between faces of an orthogonal cell constructed around atom i.