qzhu2017 / PyXtal

A code to generate atomic structure with symmetry
MIT License
234 stars 59 forks source link

distance in the periodic unit cell #251

Closed zdcao121 closed 2 months ago

zdcao121 commented 2 months ago

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:

https://github.com/qzhu2017/PyXtal/blob/344bb643d76e6e20fa72e11d05434a2446eb34da/pyxtal/wyckoff_site.py#L127

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.

qzhu2017 commented 2 months ago

@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
zdcao121 commented 2 months ago

Thanks for your reply!