I am trying to take into account periodic boundary conditions for non-orthorhombic unit cells.
I have the atomic coordinates for a monoclinic super cell with the following lattice vectors output by the Atomic Simulation Environment:
Lattice="32.816 0.0 0.0 0.0 32.976 0.0 -5.5906912278125445 0.0 31.38596137758504"
which I take to be
A1 = [32.816, 0.0, 0.0];
B1 = [0.0, 32.976, 0.0];
C1 = [-5.5906912278125445, 0.0, 31.38596137758504];
h = [A1;B1;C1];
By multiplying the position vectors by the inverse of the matrix h
, I took a coordinate transformation to obtain fractional coordinates, and now am trying to incorporate the minimum image convention:
DX = DX - floor(DX);
DY = DY - floor(DY);
DZ = DZ - floor(DZ);
before doing the back transform and then calculating distance in the standard way.
Here the lattice is not quite 0 to L due to the value of -5.5906912278125445 in one of the dimensions, and the coordinate transformation preserves this discrepancy when converting everything to fractional coordinates, i.e., DX, DY, and DZ are not 0-1. How do I incorporate the minimum image convention in this case? I'd be grateful for some insight about how to do this properly!