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!

  • $\begingroup$ Can you give an example of what you mean by “I don't recover the same coordinates at the edges of the cell”? $\endgroup$
    – wcw
    Apr 2, 2021 at 18:40
  • $\begingroup$ @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. $\endgroup$
    – user1
    Apr 2, 2021 at 22:38

1 Answer 1


There is a nice explanation here outlining the difficulties for the minimum image convention in triclinic cells.

It describes an exact approach, as well an approximate algorithm (referencing appendix C here and Tuckerman appendix B) used by many major molecular dynamics codes. This related discussion is also useful.

There is also this question from the SciComp stack exchange.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.