# Minimum image convention for non-orthorhombic unit cells

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!

• Can you give an example of what you mean by “I don't recover the same coordinates at the edges of the cell”?
– wcw
Apr 2 at 18:40
• @wcw Actually, that is not the case. I think it was a typo from an earlier version of this posting. I have updated my post. Everything should be up-to-date now. Thanks. Apr 2 at 22:38