qzhu2017 / PyXtal

A code to generate atomic structure with symmetry

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

distance in the periodic unit cell

zdcao121 opened this issue · comments

Hi, it's a nice project. While searching the proper generator in the pyxtal, the distance in the periodic unit cell is calculated as the follows:

diff -= np.floor(diff)

But the maximum effective distance between any two points is L/2 in a system with a periodic length L in one dimension. Based on this, maybe it should be replaced by the diff -= np.floor(diff+0.5) or diff -= np.rint(diff). I wonder if my understanding is correct.

@zdcao121 Thanks for your comments. You are right, np.rint or np.round should be used for distance check. I just fixed it in a recent commit with the following actions

  1. fixed the incorrect use of np.floor for distance check in several places
  2. replace np.round with np.rint according to a stack overflow discussion (though there seems to be no difference) https://stackoverflow.com/questions/56750927/difference-between-numpy-rint-and-numpy-round
  3. Cleaned up the function of search_position
  4. Add a test function for atom_site class

Thanks for your reply!