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$
    – user2026
    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 (edit: see discussion below), 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.

  • $\begingroup$ Unfortunately the "exact" approach described is incomplete, assuming I have understood the algorithm correctly - For instance it gives an incorrect answer with lattice vectors [ 1, 0; 6, 6 ] reference point [ 0, 0 ] and query point [ 3, 3 ] where the shortest distance is 3 from the image at [0,3] but the algorithm presented gives sqrt(10) for [ 1, 3 ]. I hope to work this up into an answer as I have a couple of methods that work in the general case. $\endgroup$
    – Ian Bush
    Sep 3, 2023 at 9:45
  • $\begingroup$ Hm, I have no memory of this post, but looking at it quickly I am inclined to agree with you. When I've done a version of this myself, I recall using the reciprocal lattice vectors (or, the interplane distances) to generate the full set of possibly relevant neighboring cells, which may include more than the 26 adjacent cells mentioned in the link. Then searching through all images generated by this set. That should be sufficient, yes? $\endgroup$
    – wcw
    Sep 4, 2023 at 15:03
  • 1
    $\begingroup$ Yes. The algorithm given is an inefficient method to minimise the separation in fractional coordinates, which is not the same as in Cartesian space. In the general case you have to consider further than the nearest neighbours. As I said I hope to work this up into a full answer, but while the spirit is willing the illness means the flesh is weak at the moment. $\endgroup$
    – Ian Bush
    Sep 4, 2023 at 15:17

You must log in to answer this question.