Inquiry Regarding Delta Vector

Hello.
I am seeking advice regarding the utilization of the delta_vector method in OVITO for calculating the vector between two particles. The particle coordinates can be found in the dump file below.

Additionally, I have employed the formula outlined in the book (Allen, M. P., & Tildesley, D. J. (2017). Computer simulation of liquids (2nd ed.). Oxford University Press.) to compute the vector between the two particles. The formula is as follows:
formula

I have noticed discrepancies in the obtained vectors along the x-direction.
Thanks in advance. Below is my data processing code:

from ovito.io import import_file
import numpy as np


def my_vec(atom_i_pos, atom_j_pos, box_length, strain):
    ji_vec = atom_j_pos - atom_i_pos
    ji_vec[0] = ji_vec[0] - np.round(ji_vec[1] / box_length) * box_length * strain
    ji_vec[0] = ji_vec[0] - np.round(ji_vec[0] / box_length) * box_length
    ji_vec[1] = ji_vec[1] - np.round(ji_vec[1] / box_length) * box_length
    ji_vec[2] = ji_vec[2] - np.round(ji_vec[2] / box_length) * box_length
    return ji_vec


def main():
    pipeline_atoms = import_file("./tst.colloid").compute(0)
    box_length, strain = pipeline_atoms.cell[0, 0], pipeline_atoms.cell[0, 1] / pipeline_atoms.cell[0, 0]
    vector = pipeline_atoms.particles.delta_vector(0, 1, pipeline_atoms.cell)
    my_vector = my_vec(pipeline_atoms.particles["Position"][0], pipeline_atoms.particles["Position"][1], box_length, strain)
    print(vector)  # output [8.67939 1.92258 1.24118]
    print(my_vector)  # output [-7.00447108  1.92258     1.24118   ]


if __name__ == '__main__':
    main()

Dump File:
tst.colloid (254 Bytes)

The challenge of determining the distance between two particles arises due to periodic boundary conditions. In this context, the minimum image convention has to be used to identify the closest pair of particles. The minimum image convention is defined as “each individual particle in the simulation interacts with the closest image of the remaining particles in the system”.

The method you described calculates the distance by identifying the nearest particle in Cartesian space. Conversely, OVITO employs reduced coordinates to determine this distance. When working with sheared cells, these two approaches may not identify the same periodic image as the closest one for subsequent distance calculation.

The image below illustrates the difference: Your method links the two particles across the periodic boundary, whereas OVITO connects them within the primary cell. This discrepancy results in the two different Cartesian distances calculated by your code.

In reduced coordinates, which are scaled by a factor of 10 for better visibility, the distance within the primary cell—as determined by OVITO - becomes the shorter one.

I hope this explains your observation. Depending on your use case, there might be different workarounds if needed.

Thank you for your response. Could you please clarify if “reduced coordinates” refer to the coordinates obtained by affine transformation of particle coordinates from a deformed box to an orthogonal box? Additionally, I’m unsure why OVITO utilizes these reduced coordinates for distance calculations. How can one avoid using reduced coordinates in OVITO?

Could you please clarify if “reduced coordinates” refer to the coordinates obtained by affine transformation of particle coordinates from a deformed box to an orthogonal box?

The fractional coordinate system gives the position of a particle in reference to the cell vectors.

From the vasp wiki:

Here, the ion positions {{ec R}} (in A) are listed. The first line selects one of the two possible modes how the coordinates {isplaystyle x_{1},x_{2}} and {isplaystyle x_{3}} given in the following lines are interpreted:

  • “Direct” means the positions are provided in direct (fractional) coordinates: {isplaystyle {ec {R}}=x_{1}{ec {a}}{1}+x{2}{ec {a}}{2}+x{3}{ec {a}}_{3},}where {{ec R}} is the position vector of an ion.

Yes, this corresponds to an affine transformation of the particles into a cube with unit edge length.

I’m unsure why OVITO utilizes these reduced coordinates for distance calculations.

It accelerates the process of finding the correct nearest periodic image of the requested particle. Otherwise one would need to manually check all 27 neighbors.

Additionally, I’m unsure why OVITO utilizes these reduced coordinates for distance calculations.

The actual distance is calculated in Cartesian coordinate space. The reduced coordinates are only used to identify the right periodic image of the atoms.

How can one avoid using reduced coordinates in OVITO?

You would need to hand roll your own “delta vector” function. Here, I would recommend to using the replicate modifier to generate the periodic images and afterwards calculating the distance of particle A to all 27 images of particle B and storing the closest distance.