MaginnGroup / Cassandra

Cassandra is a Monte Carlo package to conduct atomistic simulations.
https://cassandra.nd.edu/
GNU General Public License v3.0
41 stars 20 forks source link

Minimium image distance in a triclinic box #110

Open ryangmullen opened 3 years ago

ryangmullen commented 3 years ago

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

  1. In the input file, create a triclinic box with lattice vectors a = (1, 0, 0), b = (1/2, sqrt(3)/2, 0), c = (0, 0, 1). This can be accomplished by adding the following section to a CASSANDRA input file:
    # Box_Info
    1
    cell_matrix
    1.000000  0.500000  0.000000
    0.000000  0.866025  0.000000
    0.000000  0.000000  1.000000
  2. Create a system with two atoms at scaled positions (1/3, 1/3, 0) and (7/8, 7/8, 0). This can be accomplished by creating an xyz file with the following content:
    2
    # BOX: 1.000000 1.000000 1.000000 90. 90. 60.
    LJ  0.500000  0.288675  0.000000
    LJ  1.312500  0.757772  0.000000

    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.

rwsmith7531 commented 1 year 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.